From 13ecb4a0932cf486f76ad66f5d41bc7784817c10 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <art1@andreas-romeyke.de>
Date: Fri, 16 Oct 2020 10:38:57 +0200
Subject: [PATCH] - improved report using strftime - if read fails, print out
 the read block

---
 deep_fixitycheck.pl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/deep_fixitycheck.pl b/deep_fixitycheck.pl
index fe69cdb..b7089bd 100644
--- a/deep_fixitycheck.pl
+++ b/deep_fixitycheck.pl
@@ -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");
-- 
GitLab