From 693d93f649b4a5879a416886310d845c480af2c6 Mon Sep 17 00:00:00 2001 From: John Bowdre Date: Mon, 22 Aug 2022 16:58:37 -0500 Subject: [PATCH] handle files deleted at source --- client/build/sync.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/build/sync.sh b/client/build/sync.sh index 3fecd9b..44e50d1 100644 --- a/client/build/sync.sh +++ b/client/build/sync.sh @@ -10,10 +10,14 @@ fi echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync sync starts NOW!" # sync -/usr/bin/rsync --bwlimit=${SYNC_MAX_BW:-0} -e "ssh -l syncer -p ${SYNC_PORT:-2222} -i /syncer/.ssh/id_syncer -o StrictHostKeyChecking=no" -av --exclude '*.json' $SYNC_PEER:/ /syncer/library +/usr/bin/rsync --progress --bwlimit=${SYNC_MAX_BW:-0} -e "ssh -l syncer -p ${SYNC_PORT:-2222} -i /syncer/.ssh/id_syncer -o StrictHostKeyChecking=no" -avh --stats --exclude '*.json' --exclude '.vSphere-HA' $SYNC_PEER:/ /syncer/library --delete || [ $? -eq 23 ] && true + +# handle removed files / remove directories +grep '"files": \[\]' /syncer/library/*/item.json -l | xargs rm -f $1 +find /syncer/library -type d -empty -delete # generate content library manifest echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Generating content library manifest..." /usr/bin/python3 /syncer/update_library_manifests.py -n "${LIBRARY_NAME:-Library}" -p /syncer/library/ -echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync tasks complete!" \ No newline at end of file +echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync tasks complete!"