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

- minor fix in progress bar

- stat-size calculated with filesizes instead using df
- improved report
parent 88d1b20d
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ sub searching_ie_files ($$) { ...@@ -59,7 +59,7 @@ sub searching_ie_files ($$) {
if (-d $_) { $first_two_levels_of_dirs++;} if (-d $_) { $first_two_levels_of_dirs++;}
}; };
find( $wanted_twolevel_dircount, $dir); find( $wanted_twolevel_dircount, $dir);
my $progressbar=Time::Progress->new(min => 0, max => $first_two_levels_of_dirs-1, smoothing => 1); my $progressbar=Time::Progress->new(min => 0, max => $first_two_levels_of_dirs, smoothing => 1);
my $dircount = 0; my $dircount = 0;
my $wanted_process_sip = sub { my $wanted_process_sip = sub {
if (-f && m/V(\d+)-IE\d+\.xml$/) { if (-f && m/V(\d+)-IE\d+\.xml$/) {
...@@ -73,7 +73,7 @@ sub searching_ie_files ($$) { ...@@ -73,7 +73,7 @@ sub searching_ie_files ($$) {
$relpath =~ s{^\Q$dir\E/?}{}; $relpath =~ s{^\Q$dir\E/?}{};
my $depth = File::Spec->splitdir($relpath); my $depth = File::Spec->splitdir($relpath);
if ($depth <= 2) { if ($depth <= 2) {
print $progressbar->report("find IE files: %40b ETA: %E \r", $dircount++); print $progressbar->report("find IE files: %40b running: %L ETA: %E (count=$dircount)\r", ++$dircount);
} }
} }
return; return;
...@@ -317,16 +317,17 @@ if (defined $search_dir && -d "$search_dir") { ...@@ -317,16 +317,17 @@ if (defined $search_dir && -d "$search_dir") {
say "checking IEs"; say "checking IEs";
my $fh_unsorted_file = $tmp_ies_unsorted_file->openr(); my $fh_unsorted_file = $tmp_ies_unsorted_file->openr();
my $count = 0; my $count = 0;
my $progressbar = Time::Progress->new(min=>0, max=>$cnt_unsorted_files-1, smoothing => 1); my $progressbar = Time::Progress->new(min=>0, max=>$cnt_unsorted_files, smoothing => 1);
my $stat; my $stat;
$stat->{IEs} = 0; $stat->{IEs} = 0;
$stat->{files} = 0; $stat->{files} = 0;
$stat->{errors} = 0; $stat->{errors} = 0;
$stat->{scansize} = 0;
$stat->{begin} = time; $stat->{begin} = time;
while ( <$fh_unsorted_file>) { # scan each IE while ( <$fh_unsorted_file>) { # scan each IE
$stat->{IEs}++; $stat->{IEs}++;
chomp; chomp;
print $progressbar->report("parse IE files: %40b ETA: %E \r", $count++); print $progressbar->report("parse IE files: %40b running: %L ETA: %E (count=$count) \r", ++$count);
my $ret = parse_iexml( $_, $recovery); my $ret = parse_iexml( $_, $recovery);
foreach my $fileobj (@{ $ret->{files} }) { foreach my $fileobj (@{ $ret->{files} }) {
$fileobj->{file_mounted} = map_file($map_path, $fileobj->{filepath}); $fileobj->{file_mounted} = map_file($map_path, $fileobj->{filepath});
...@@ -338,6 +339,7 @@ if (defined $search_dir && -d "$search_dir") { ...@@ -338,6 +339,7 @@ if (defined $search_dir && -d "$search_dir") {
# only if file exists, do additional checks # only if file exists, do additional checks
$result = check_file_size($fileobj, $result); $result = check_file_size($fileobj, $result);
if ($result->{size}) { if ($result->{size}) {
$stat->{scansize} += $result->{size};
$result = check_file_seekable($fileobj, $result); $result = check_file_seekable($fileobj, $result);
if ($result->{seekable}) { if ($result->{seekable}) {
foreach my $fixity_algorithm (@algorithms) { foreach my $fixity_algorithm (@algorithms) {
...@@ -349,10 +351,12 @@ if (defined $search_dir && -d "$search_dir") { ...@@ -349,10 +351,12 @@ if (defined $search_dir && -d "$search_dir") {
} }
} }
if ($result->{errors} > 0) { if ($result->{errors} > 0) {
path($report_file)->append_utf8("IE $_ with following errors:\n"); my $timestamp = localtime;
path($report_file)->append_utf8("$timestamp, IE $_ with following errors:\n");
foreach my $errors (@{ $result->{error_description} }) { foreach my $errors (@{ $result->{error_description} }) {
path($report_file)->append_utf8("\t$errors\n"); path($report_file)->append_utf8("\t$errors\n");
} }
path($report_file)->append_utf8("-"x60,"\n");
$stat->{errors} += $result->{errors}; $stat->{errors} += $result->{errors};
} }
} }
...@@ -361,8 +365,24 @@ if (defined $search_dir && -d "$search_dir") { ...@@ -361,8 +365,24 @@ if (defined $search_dir && -d "$search_dir") {
say ""; say "";
$stat->{end} = time; $stat->{end} = time;
$stat->{duration} = $stat->{end} - $stat->{begin}; $stat->{duration} = $stat->{end} - $stat->{begin};
$stat->{scansize} = `du -hs $search_dir`; my $human_readable_size;
my $summary = "Scanned $stat->{IEs} IEs with $stat->{files} files ($stat->{scansize}) in $stat->{duration} seconds, found $stat->{errors} errors"; my $fac_tera = 1024*1024*1024*1024;
my $fac_giga = 1024*1024*1024;
my $fac_mega = 1024*1024;
my $fac_kilo = 1024;
if ($stat->{scansize} > $fac_tera) { $human_readable_size = sprintf "%03.1fTB", $stat->{scansize} / $fac_tera}
elsif ($stat->{scansize} > $fac_giga) {$human_readable_size = sprintf "%03.1fGB", $stat->{scansize} / $fac_giga}
elsif ($stat->{scansize} > $fac_mega) {$human_readable_size = sprintf "%03.1fMB", $stat->{scansize} / $fac_mega}
elsif ($stat->{scansize} > $fac_kilo) {$human_readable_size = sprintf "%03.1fkB", $stat->{scansize} / $fac_kilo}
else {$human_readable_size = $stat->{scansize} . "B";}
path($report_file)->append_utf8("="x60,"\n");
my $summary = sprintf ("Scanned %d IEs with %d files (%s) in %d seconds, found %d errors",
$stat->{IEs},
$stat->{files},
$human_readable_size,
$stat->{duration},
$stat->{errors}
);
path($report_file)->append_utf8("$summary\n"); path($report_file)->append_utf8("$summary\n");
say $summary; say $summary;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment