From a32d24a08613a1d0f5d0ca8afd1f41520404c86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Tue, 4 Mar 2025 09:46:02 +0100 Subject: [PATCH] phpsg.sh: Remove files which are no longer found in SOURCE_DIR. --- phpsg.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpsg.sh b/phpsg.sh index 5839ede..79fd2fd 100755 --- a/phpsg.sh +++ b/phpsg.sh @@ -116,3 +116,13 @@ export -f process_file find "$SOURCE_DIR" -type f -not -name '*.cfg.php' | parallel -j"${JOBS}" process_file + +SOURCE_FILE_LIST=$(cd "$SOURCE_DIR" && find . -type f -and -not -name '*.cfg.php' | sed 's/.php$//') +OUTPUT_FILE_LIST=$(cd "$OUTPUT_DIR" && find . -type f) + +for file in $(echo "${SOURCE_FILE_LIST[@]}" "${OUTPUT_FILE_LIST[@]}" | tr ' ' '\n' | sort | uniq -u) +do + FILE_PATH=$(realpath --relative-base=./ "$OUTPUT_DIR/$file") + echo "Deleting file $FILE_PATH" + rm "$FILE_PATH" +done