[Fai-commit] r2979 - people/eartoast/bugfix/297550/scripts
fai-repository at svn.debian.org
fai-repository at svn.debian.org
Thu Nov 3 18:05:39 UTC 2005
Author: glaweh-guest
Date: 2005-11-03 18:05:38 +0000 (Thu, 03 Nov 2005)
New Revision: 2979
Modified:
people/eartoast/bugfix/297550/scripts/fcopy
Log:
* BUGFIX:297550 clean up the fcopy recursion code
the File::Find code used in recursive fcopy descended into the ignored
directories and their subdirectories. this failed when a revision control
system keeps subdirectories there (in this case: subversion).
while fixing this bug, the whole File::Find code was brought to a more
readable/debuggable form.
this version differs from the first version sent to fai-workshow at guug.de
because it moves the newly introduced %ignoredirs out of global scope.
Modified: people/eartoast/bugfix/297550/scripts/fcopy
===================================================================
--- people/eartoast/bugfix/297550/scripts/fcopy 2005-11-03 18:02:50 UTC (rev 2978)
+++ people/eartoast/bugfix/297550/scripts/fcopy 2005-11-03 18:05:38 UTC (rev 2979)
@@ -342,20 +342,6 @@
exit 0;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-sub rfilter {
-
- # Filter for recursive copying
-
- # are we in a directory ? should we ignore it ?
- my $location=$_;
- (-d and (! grep $location eq $_, at ignoredirs )) or return 0;
- # a directory without subdirs has two hard links
- # don't count @ignoredirs as subdirs
- my $subdirs=(lstat($_))[3] - 2 - grep(-d, at ignoredirs);
- # push leaf
- push @rlist,$File::Find::name unless $subdirs;
-}
-# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main program
$|=1;
@@ -396,8 +382,20 @@
if ($opt_r) {
foreach (@ARGV) { $_="$source/$_"; } # add prefix to list of directories
- File::Find::find(\&rfilter, at ARGV);
- foreach (@rlist) { $_=~ s#^$source/##; } # remove prefix from all fines found
+ my %has_subdirs;
+ my %ignoredirs;
+ map $ignoredirs{$_}=1, at ignoredirs;
+ File::Find::find({
+ wanted=>sub{ $has_subdirs{$File::Find::dir} |= -d},
+ preprocess=>sub{grep ! (-d and exists($ignoredirs{$_})), at _}},
+ @ARGV);
+ foreach (keys %has_subdirs) {
+ unless ($has_subdirs{$_}) {
+ # remove prefix from all files found
+ s#^$source/##;
+ push @rlist,$_;
+ }
+ }
warn "List of all files found by File::Find::find: @rlist" if $debug;
@ARGV = @rlist;
}
More information about the Fai-commit
mailing list