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

- improved report using strftime

- if read fails, print out the read block
parent b70f03c8
Branches
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@ use Digest::MD5;
use Digest::SHA;
use Pod::Usage;
use IO::Handle;
use POSIX qw(strftime);
use Fcntl qw(SEEK_END SEEK_SET);
STDOUT->autoflush(1);
# guarantee, that output will be UTF8
......@@ -265,17 +266,20 @@ sub check_file_fixities($$) {
my $fh = path($fileobj->{file_mounted})->openr();
binmode($fh);
my $buffer;
my $block=0;
my $blocksize = 8*1024; # 8kB blocks
while (1) {
my $ret = read($fh, $buffer, 128*1024);# 128kB blocks
my $ret = read($fh, $buffer, $blocksize);
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, $!");
add_error($fileobj, $result, "read error in block $block (blocksize=$blocksize), $!");
last;
}
$block++;
}
close ($fh);
foreach my $fixity_algorithm (keys %digest_mapping) {
......@@ -367,8 +371,9 @@ if (defined $search_dir && -d "$search_dir") {
}
}
}
if ($result->{errors} > 0) {
my $timestamp = localtime;
my $timestamp = strftime("%Y-%m-%d %H:%M:%S", gmtime(time));
path($report_file)->append_utf8("$timestamp, IE $_ with following errors:\n");
foreach my $errors (@{ $result->{error_description} }) {
path($report_file)->append_utf8("\t$errors\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment