🔨 Keep DEST_DIR and SOURCE_DIR in sync
This commit is contained in:
parent
1c2996acc4
commit
aae3847a46
|
@ -69,21 +69,8 @@ find -L "$SOURCE_DIR" -type f -name "*.md" -exec grep -q "publish: true" {} \; -
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Log the script execution
|
# Delete files in DEST_DIR that don't exist in SOURCE_DIR anymore
|
||||||
echo "Executing cleanup script at $(date)"
|
find "$DEST_DIR" -type f -exec sh -c '[ ! -e "$SOURCE_DIR/${1#$DEST_DIR/}" ] && rm "$1"' _ {} \;
|
||||||
|
|
||||||
# Find files in DEST_DIR that don't exist in SOURCE_DIR and delete them
|
|
||||||
find "$DEST_DIR" -type f -exec sh -c '
|
|
||||||
relative_path=${1#$DEST_DIR/}
|
|
||||||
source_file="$SOURCE_DIR/$relative_path"
|
|
||||||
|
|
||||||
if [ ! -e "$source_file" ]; then
|
|
||||||
echo "Deleting $1 as it doesn't exist in SOURCE_DIR"
|
|
||||||
rm "$1"
|
|
||||||
else
|
|
||||||
echo "Skipping $1 as it exists in SOURCE_DIR"
|
|
||||||
fi
|
|
||||||
' _ {} \;
|
|
||||||
|
|
||||||
# Print the log file
|
# Print the log file
|
||||||
cat "$LOG_FILE"
|
cat "$LOG_FILE"
|
||||||
|
|
Loading…
Reference in New Issue