From a3b0ef5c7800de3316a6b78b074f573ea872e2f5 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <art1@andreas-romeyke.de>
Date: Thu, 16 Dec 2021 11:27:47 +0100
Subject: [PATCH] - bugfix, if a large file has many errors the memory
 consumption was very   impressive, therefore the error reporting is changed
 to reduce footprint

---
 deep_fixitycheck.pl | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/deep_fixitycheck.pl b/deep_fixitycheck.pl
index 0922121..9704f0a 100644
--- a/deep_fixitycheck.pl
+++ b/deep_fixitycheck.pl
@@ -213,7 +213,8 @@ sub add_error ($$$) {
   my $result = shift;
   my $errormessage = shift;
   $result->{errors}++;
-  push @{$result->{error_description}}, "file $fileobj->{file_mounted} (original: $fileobj->{filepath}) $errormessage";
+  my $report_path = $result->{report_path};
+  $report_path->append_utf8( "file $fileobj->{file_mounted} (original: $fileobj->{filepath}) $errormessage");
   return $result;
 }
 
@@ -335,12 +336,15 @@ sub stage2 ($$$$) {
     chomp;
     my $transferrate_in_MBs = sprintf("%0.2f", $stat->{scansize} / (time - $stat->{begin} + 1) / 1024 / 1024);
     print $progressbar->report("parse IE files:       %40b  running: %L ETA: %E ($count/$cnt_unsorted_files IEs, tfr=$transferrate_in_MBs MB/s)         \r", ++$count);
+    my $timestamp = strftime("%Y-%m-%d %H:%M:%S %z (%Z)", localtime(time));
+    $report_path->append_utf8("$timestamp, IE $_ with following errors:\n");
     my $ret = parse_iexml($_, $recovery);
     foreach my $fileobj (@{$ret->{files}}) {
       $fileobj->{file_mounted} = map_file($map_path, $fileobj->{filepath});
       $stat->{files}++;
       my $result;
       $result->{errors} = 0;
+      $result->{report_path} = $report_path;
       $result = check_if_file_exist($fileobj, $result);
       if ($result->{exist}) {
         # only if file exists, do additional checks
@@ -355,11 +359,6 @@ sub stage2 ($$$$) {
       }
 
       if ($result->{errors} > 0) {
-        my $timestamp = strftime("%Y-%m-%d %H:%M:%S %z (%Z)", localtime(time));
-        $report_path->append_utf8("$timestamp, IE $_ with following errors:\n");
-        foreach my $errors (@{$result->{error_description}}) {
-          $report_path->append_utf8("\t$errors\n");
-        }
         $report_path->append_utf8("-" x 60, "\n");
         $stat->{errors} += $result->{errors};
       }
-- 
GitLab