added control of the already processed files

This commit is contained in:
Daniel Sosnowski
2026-01-16 12:24:09 +01:00
parent 435b1668ee
commit 83045533ee

37
pdt.sh
View File

@@ -1,33 +1,24 @@
#!/bin/bash #!/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 readarray -t files < /var/www/html/storage/focode/file_list_temp.txt
for file in "${files[@]}" for file in "${files[@]}"
do 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") if [[ -f "/var/www/html/storage/focode/processed_files.txt" && $(grep -c "$file" "/var/www/html/storage/focode/processed_files.txt") -gt 0 ]]
echo "$processed_file" >> /var/www/html/storage/focode/processed_files.txt then
echo "Skipping already processed file: $file"
continue
fi
if [[ $output -gt 0 ]] output=$(php compress.php process "$file")
then if [[ $output -gt 0 ]]
echo "ERROR! Exiting the program" then
echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" echo "ERROR! Exiting the program"
echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log"
exit 1 echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log"
fi exit 1
fi
echo "Processed file: $file - $output" echo "Processed file: $file - $output" | tee -a /var/www/html/storage/focode/processed_files.txt
done
done done