]> git.proxmox.com Git - pmg-api.git/commitdiff
fix bug #1636: correctly track file modification time
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 29 Jan 2018 10:05:51 +0000 (11:05 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 29 Jan 2018 10:05:51 +0000 (11:05 +0100)
Turns out that perl -M is conceptually wrong, so we use CORE::stat
instead.

PMG/Cluster.pm
PMG/Utils.pm

index 2693bfd2c16a69d4423e39c2b766d5520ca6e2d2..5d7d29c6e78538c3a1289730654bbe8d00691fad 100644 (file)
@@ -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";
 
index 412209efd11439fe00d566dbb66a538f6760f495..a78728e559a116a18ee01f06ce1665b0deee0e24 100644 (file)
@@ -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(