Matthew Booth
2010-May-07 14:03 UTC
[Libguestfs] [PATCH] Config: Check timestamps on directories when rebuilding transfer iso
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
Richard W.M. Jones
2010-May-07 14:20 UTC
[Libguestfs] [PATCH] Config: Check timestamps on directories when rebuilding transfer iso
On Fri, May 07, 2010 at 03:03:33PM +0100, Matthew Booth wrote:> We don't currently detect if a file with an old timestamp has been moved into a > directory. This fixes that.Why don't we just always rebuild the ISO? Surely mkisofs can't take that long? Anyway, change looks fine, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Reasonably Related Threads
- [PATCH] Unconditionally always rebuild the transfer iso
- [PATCH] Config: Don't require all referenced software to be available
- [PATCH] Move all interaction with the config file into Sys::VirtV2V::Config
- [PATCH 1/2] Config: NFC: always create and pass round a Config object
- [PATCH] Fix error in Converter::Windows when there is no transfer iso