[Libguestfs] [PATCH] Config: Check timestamps on directories when rebuilding transfer iso

Matthew Booth mbooth at redhat.com
Fri May 7 14:03:33 UTC 2010


We don't currently detect if a file with an old timestamp has been moved into a
directory. This fixes that.
---
 lib/Sys/VirtV2V/Config.pm |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/Sys/VirtV2V/Config.pm b/lib/Sys/VirtV2V/Config.pm
index 3fff455..bb30dae 100644
--- a/lib/Sys/VirtV2V/Config.pm
+++ b/lib/Sys/VirtV2V/Config.pm
@@ -154,6 +154,7 @@ sub get_transfer_iso
         if ($iso_st->mtime > $config_st->mtime) {
             my $rebuild = 0;
 
+            my %dirs;
             foreach my $path (keys(%paths)) {
                 my $path_st = stat($path);
 
@@ -161,6 +162,19 @@ sub get_transfer_iso
                     $rebuild = 1;
                     last;
                 }
+
+                # Also check if the containing directory has been updated. This
+                # will pick up the case where a file with an old timestamp has
+                # been moved into a directory.
+                my (undef, $dir, undef) = File::Spec->splitpath($path);
+                if (!exists($dirs{$dir})) {
+                    my $dir_st = stat($dir);
+                    if ($dir_st->mtime > $iso_st->mtime) {
+                        $rebuild = 1;
+                        last;
+                    }
+                    $dirs{$dir} = 1;
+                }
             }
 
             return $iso_path if (!$rebuild);
-- 
1.6.6.1




More information about the Libguestfs mailing list