optimized checksum checking
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Tue, 23 Aug 2011 11:18:20 +0200
changeset 81 f8fc94c18ebd
parent 80 ffde94c51cd4
child 82 ac36dbb9f773
child 85 9afa91bee25b
optimized checksum checking
bin/imager.check
--- a/bin/imager.check	Mon Aug 22 14:30:27 2011 +0200
+++ b/bin/imager.check	Tue Aug 23 11:18:20 2011 +0200
@@ -208,6 +208,7 @@
 
     my %invalid;
     foreach my $k (keys %block) {
+	state %checked;
         my $i = $block{$k};
         next if $k eq "";
         ++$done;
@@ -223,13 +224,18 @@
         }
 
         next if not $o{checksum};
+	next if $checked{$file};
 
         # checking the checksum
 	Imager::get_block($file => \my $buffer);
-        next if md5_hex($buffer) eq basename($file, qw(.gz .x .gz.x));
-        say "wrong checksum for $file\n";
-        @invalid{@$i} = ();
 
+	if (md5_hex($buffer) ne basename($file, qw(.gz .x .gz.x))) {
+	    say "wrong checksum for $file\n";
+	    @invalid{@$i} = ();
+	    next;
+	}
+
+	$checked{$file} = 1;
     }
     $SIG{ALRM}->();
     alarm 0;