From 1dc946d4661ef7306453a603f823efe9b810c2e6 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 29 Jan 2018 11:05:51 +0100 Subject: [PATCH] fix bug #1636: correctly track file modification time Turns out that perl -M is conceptually wrong, so we use CORE::stat instead. --- PMG/Cluster.pm | 3 +++ PMG/Utils.pm | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/PMG/Cluster.pm b/PMG/Cluster.pm index 2693bfd..5d7d29c 100644 --- a/PMG/Cluster.pm +++ b/PMG/Cluster.pm @@ -268,6 +268,9 @@ my $cond_commit_synced_file = sub { return 0 if $new eq $old; } + # set mtime (touch) to avoid time drift problems + utime(undef, undef, $srcfn); + rename($srcfn, $dstfn) || die "cond_rename_file '$filename' failed - $!\n"; diff --git a/PMG/Utils.pm b/PMG/Utils.pm index 412209e..a78728e 100644 --- a/PMG/Utils.pm +++ b/PMG/Utils.pm @@ -618,11 +618,13 @@ sub run_postmap { # make sure the file exists (else postmap fails) IO::File->new($filename, 'a', 0644); - my $age_src = -M $filename // 0; - my $age_dst = -M "$filename.db" // 10000000000; + my $mtime_src = (CORE::stat($filename))[9] // + die "unbale to read mtime of $filename\n"; + + my $mtime_dst = (CORE::stat("$filename.db"))[9] // 0; # if not changed, do nothing - return if $age_src > $age_dst; + return if $mtime_src <= $mtime_dst; eval { PVE::Tools::run_command( -- 2.39.2