diff --git a/deep_fixitycheck.pl b/deep_fixitycheck.pl index 694b9217b3cfc39cd3c3a7b44209a7fd93269676..62c6b15c27d5017f44e7ec7d8961e44ebd845a6b 100644 --- a/deep_fixitycheck.pl +++ b/deep_fixitycheck.pl @@ -59,7 +59,7 @@ sub searching_ie_files ($$) { if (-d $_) { $first_two_levels_of_dirs++;} }; 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 $wanted_process_sip = sub { if (-f && m/V(\d+)-IE\d+\.xml$/) { @@ -73,7 +73,7 @@ sub searching_ie_files ($$) { $relpath =~ s{^\Q$dir\E/?}{}; my $depth = File::Spec->splitdir($relpath); 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; @@ -317,16 +317,17 @@ if (defined $search_dir && -d "$search_dir") { say "checking IEs"; my $fh_unsorted_file = $tmp_ies_unsorted_file->openr(); 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; $stat->{IEs} = 0; $stat->{files} = 0; $stat->{errors} = 0; + $stat->{scansize} = 0; $stat->{begin} = time; while ( <$fh_unsorted_file>) { # scan each IE $stat->{IEs}++; 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); foreach my $fileobj (@{ $ret->{files} }) { $fileobj->{file_mounted} = map_file($map_path, $fileobj->{filepath}); @@ -338,6 +339,7 @@ if (defined $search_dir && -d "$search_dir") { # only if file exists, do additional checks $result = check_file_size($fileobj, $result); if ($result->{size}) { + $stat->{scansize} += $result->{size}; $result = check_file_seekable($fileobj, $result); if ($result->{seekable}) { foreach my $fixity_algorithm (@algorithms) { @@ -349,10 +351,12 @@ if (defined $search_dir && -d "$search_dir") { } } 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} }) { path($report_file)->append_utf8("\t$errors\n"); } + path($report_file)->append_utf8("-"x60,"\n"); $stat->{errors} += $result->{errors}; } } @@ -361,8 +365,24 @@ if (defined $search_dir && -d "$search_dir") { say ""; $stat->{end} = time; $stat->{duration} = $stat->{end} - $stat->{begin}; - $stat->{scansize} = `du -hs $search_dir`; - my $summary = "Scanned $stat->{IEs} IEs with $stat->{files} files ($stat->{scansize}) in $stat->{duration} seconds, found $stat->{errors} errors"; + my $human_readable_size; + 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"); say $summary; } else {