bin/imager.check
changeset 81 f8fc94c18ebd
parent 72 2a7ab8422dd6
child 85 9afa91bee25b
equal deleted inserted replaced
80:ffde94c51cd4 81:f8fc94c18ebd
   206     };
   206     };
   207     $SIG{ALRM}->();
   207     $SIG{ALRM}->();
   208 
   208 
   209     my %invalid;
   209     my %invalid;
   210     foreach my $k (keys %block) {
   210     foreach my $k (keys %block) {
       
   211 	state %checked;
   211         my $i = $block{$k};
   212         my $i = $block{$k};
   212         next if $k eq "";
   213         next if $k eq "";
   213         ++$done;
   214         ++$done;
   214 
   215 
   215         my ($file) =
   216         my ($file) =
   221             @invalid{@$i} = ();
   222             @invalid{@$i} = ();
   222             next;
   223             next;
   223         }
   224         }
   224 
   225 
   225         next if not $o{checksum};
   226         next if not $o{checksum};
       
   227 	next if $checked{$file};
   226 
   228 
   227         # checking the checksum
   229         # checking the checksum
   228 	Imager::get_block($file => \my $buffer);
   230 	Imager::get_block($file => \my $buffer);
   229         next if md5_hex($buffer) eq basename($file, qw(.gz .x .gz.x));
   231 
   230         say "wrong checksum for $file\n";
   232 	if (md5_hex($buffer) ne basename($file, qw(.gz .x .gz.x))) {
   231         @invalid{@$i} = ();
   233 	    say "wrong checksum for $file\n";
   232 
   234 	    @invalid{@$i} = ();
       
   235 	    next;
       
   236 	}
       
   237 
       
   238 	$checked{$file} = 1;
   233     }
   239     }
   234     $SIG{ALRM}->();
   240     $SIG{ALRM}->();
   235     alarm 0;
   241     alarm 0;
   236 
   242 
   237     # invalid now contains the numbers of the idx files beiing
   243     # invalid now contains the numbers of the idx files beiing