Skip to content
Snippets Groups Projects
Commit b70f03c8 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- add read error detection

parent d3ed0af3
Branches
No related tags found
No related merge requests found
...@@ -265,9 +265,16 @@ sub check_file_fixities($$) { ...@@ -265,9 +265,16 @@ sub check_file_fixities($$) {
my $fh = path($fileobj->{file_mounted})->openr(); my $fh = path($fileobj->{file_mounted})->openr();
binmode($fh); binmode($fh);
my $buffer; my $buffer;
while (read($fh, $buffer, 128*1024)) { # 128kB blocks while (1) {
foreach my $fixity_algorithm (keys %digest_mapping) { my $ret = read($fh, $buffer, 128*1024);# 128kB blocks
$digest_mapping{$fixity_algorithm}->add($buffer); if (defined $ret) {
last if 0 == $ret; # EOF
foreach my $fixity_algorithm (keys %digest_mapping) {
$digest_mapping{$fixity_algorithm}->add($buffer);
}
} else {
add_error($fileobj, $result, "read error, $!");
last;
} }
} }
close ($fh); close ($fh);
...@@ -276,7 +283,6 @@ sub check_file_fixities($$) { ...@@ -276,7 +283,6 @@ sub check_file_fixities($$) {
$result->{fixity}->{$fixity_algorithm} = $digest_mapping{$fixity_algorithm}->hexdigest(); $result->{fixity}->{$fixity_algorithm} = $digest_mapping{$fixity_algorithm}->hexdigest();
if ($result->{fixity}->{$fixity_algorithm} ne $fileobj->{fixity}->{$fixity_algorithm}) { if ($result->{fixity}->{$fixity_algorithm} ne $fileobj->{fixity}->{$fixity_algorithm}) {
add_error($fileobj, $result, "has fixity $result->{fixity}->{$fixity_algorithm} for algorithm $fixity_algorithm, but $fileobj->{fixity}->{$fixity_algorithm} was expected"); add_error($fileobj, $result, "has fixity $result->{fixity}->{$fixity_algorithm} for algorithm $fixity_algorithm, but $fileobj->{fixity}->{$fixity_algorithm} was expected");
die;
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment