From 435b1668eecc193d0635fa116b69f2c8bcdb6570 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Thu, 15 Jan 2026 16:24:17 +0100 Subject: [PATCH] Skipping processed files --- pdt.sh | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/pdt.sh b/pdt.sh index 48e88f1..1a8ffe7 100644 --- a/pdt.sh +++ b/pdt.sh @@ -1,17 +1,33 @@ #!/bin/bash +if [[ -f /var/www/html/storage/focode/processed_files.txt]] +then + readarray -t processed_files < /var/www/html/storage/focode/processed_files.txt +fi + readarray -t files < /var/www/html/storage/focode/file_list_temp.txt for file in "${files[@]}" do - output=$(php compress.php process "$file") - if [[ $output -gt 0 ]] - then - echo "ERROR! Exiting the program" - echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" - echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" - exit 1 - fi + for processed_file in "${processed_files[@]}" + do + if [[ "$file" == "$processed_file" ]] + then + echo "Skipping already processed file: $file" + continue + fi - echo "Processed file: $file - $output" + output=$(php compress.php process "$file") + echo "$processed_file" >> /var/www/html/storage/focode/processed_files.txt + + if [[ $output -gt 0 ]] + then + echo "ERROR! Exiting the program" + echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" + echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" + exit 1 + fi + + echo "Processed file: $file - $output" + done done \ No newline at end of file