From 83045533ee3a385d7dd4ddd2ee905f84b551a1d2 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Fri, 16 Jan 2026 12:24:09 +0100 Subject: [PATCH] added control of the already processed files --- pdt.sh | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/pdt.sh b/pdt.sh index 1a8ffe7..b2a5795 100644 --- a/pdt.sh +++ b/pdt.sh @@ -1,33 +1,24 @@ #!/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 - for processed_file in "${processed_files[@]}" - do - if [[ "$file" == "$processed_file" ]] - then - echo "Skipping already processed file: $file" - continue - fi - output=$(php compress.php process "$file") - echo "$processed_file" >> /var/www/html/storage/focode/processed_files.txt + if [[ -f "/var/www/html/storage/focode/processed_files.txt" && $(grep -c "$file" "/var/www/html/storage/focode/processed_files.txt") -gt 0 ]] + then + echo "Skipping already processed file: $file" + continue + fi - 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 + 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 - echo "Processed file: $file - $output" - done + echo "Processed file: $file - $output" | tee -a /var/www/html/storage/focode/processed_files.txt done \ No newline at end of file