summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2022-03-05 12:11:17 +0000
committerPaul Buetow <paul@buetow.org>2022-03-05 12:11:17 +0000
commit65d756e975483704ceebf7551f7a855e5aafdfc8 (patch)
tree1f579686afbdc1d5eb649a68411ecb9730141f27
parentf4473fd7416f9a362d8ea79e2262c8aafef410f0 (diff)
Auto cleaning when photo vanished from incoming dir
-rwxr-xr-xsrc/photoalbum.sh16
1 files changed, 16 insertions, 0 deletions
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