Updated "drop-redundant-rsync" patch attached...

-- 
Kees Cook                                            @debian.org
Description: drop the needless section of rsync code for trailing list.
Author: Kees Cook <[email protected]>
Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=455082

Index: debmirror-2.4.4/debmirror
===================================================================
--- debmirror-2.4.4.orig/debmirror	2010-04-05 11:37:55.000000000 -0700
+++ debmirror-2.4.4/debmirror	2010-04-05 11:40:21.316399141 -0700
@@ -1247,12 +1247,16 @@
     my @result;
     my $i=0;
     my $j=0;
+    my @tofetch;
     $opt = "$opt --progress" if $progress;
     $opt = "$opt -v" if $verbose;
     $opt = "$opt -v" if $debug;
     $opt = "$opt -n" if $do_dry_run;
     foreach my $file (sort keys %files) {
-      if (!$files{$file}) {
+      push(@tofetch, $file) if (!$files{$file});
+    }
+    my $last = scalar(@tofetch);
+    foreach my $file (@tofetch) {
 	my $dirname;
 	my @dir;
 	($dirname) = $file =~ m:(.*/):;
@@ -1261,7 +1265,10 @@
 	  push (@result, "" . join('/', @dir[0..$_]) . "/");
 	}
 	push (@result, "$file");
-	if (++$j >= $rsync_batch) {
+	$i++;
+	$j++;
+	say("want $file ($i/$last $j/$rsync_batch)") if ($progress || $verbose);
+	if ($j >= $rsync_batch || $i == $last) {
 	  $j = 0;
 	  ($fh, $rsynctempfile) = tempfile();
 	  if (@result) {
@@ -1288,35 +1295,12 @@
 	  }
 	  @result = ();
 	}
-	if ($max_batch > 0 && ++$i >= $max_batch) {
+	if ($max_batch > 0 && ($i + 1) >= $max_batch) {
 	  print "Batch limit exceeded, mirror run will be partial\n";
 	  push (@errlog,"Batch limit exceeded, mirror run was partial\n");
 	  $num_errors++;
 	  last;
 	}
-      }
-    }
-    ($fh, $rsynctempfile) = tempfile();
-    if (@result) {
-      @result = sort(@result);
-      my $prev = "not equal to $result[0]";
-      @result = grep($_ ne $prev && ($prev = $_, 1), @result);
-      for (@result) {
-	print $fh "$_\n";
-      }
-      system ("rsync --timeout=$timeout $opt $rsyncremote --include-from=$rsynctempfile --exclude='*' $mirrordir");
-      close $fh;
-      foreach my $dest (@result) {
-	if (-f $dest) {
-	  if (!check_lists($dest)) {
-	    say("$dest failed md5sum check");
-	    $num_errors++;
-	  }
-	} elsif (!-d $dest) {
-	  say("$dest missing");
-	  $num_errors++;
-	}
-      }
     }
     return;
   };

Reply via email to