From 65d756e975483704ceebf7551f7a855e5aafdfc8 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 5 Mar 2022 12:11:17 +0000 Subject: Auto cleaning when photo vanished from incoming dir --- src/photoalbum.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/photoalbum.sh b/src/photoalbum.sh index 0f4e0f6..d4c6bd1 100755 --- a/src/photoalbum.sh +++ b/src/photoalbum.sh @@ -47,6 +47,21 @@ template () { source "$TEMPLATE_DIR/$template.tmpl" >> "$dist_html/$html" } +cleanphotos () { + find "$DIST_DIR/photos" -maxdepth 1 -type f | while read photo; do + local basename=$(basename $photo) + if [ -f "$INCOMING_DIR/$basename" ]; then + continue + fi + echo "Cleaning up $photo" + for sub in thumbs blurs photos; do + if [ -f "$DIST_DIR/$sub/$basename" ]; then + rm -v "$DIST_DIR/$sub/$basename" + fi + done + done +} + scalephotos () { cd "$INCOMING_DIR" && find ./ -maxdepth 1 -type f | sort | while read -r photo; do @@ -213,6 +228,7 @@ generate () { fi test ! -d "$DIST_DIR/photos" && mkdir -p "$DIST_DIR/photos" + cleanphotos scalephotos find "$DIST_DIR" -type f -name \*.html -delete -- cgit v1.2.3