Skip to content

Commit

Permalink
Remove empty folder just after removing a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlesage committed Jul 17, 2017
1 parent cf7b932 commit 0d19bab
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rootfs/etc/services.d/autovideoconverter/run
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ process_file() {
if [ "${AUTOMATED_CONVERSION_KEEP_SOURCE:-1}" -eq 0 ]; then
rm "$file"
log "Removed file '$file'."
# Remove directory if empty (hidden files/folders are ignored).
filedir="$(dirname "$file")"
if [ -z "$(ls "$filedir")" ]; then
log "Removed directory '$filedir'."
rm -rf "$filedir"
fi
fi
else
log "Conversion failed."
Expand Down Expand Up @@ -146,11 +152,6 @@ while true; do
done 3<"$FILELIST"
rm "$FILELIST"
log "Watch folder processing terminated."

# Remove empty directories.
if [ "${AUTOMATED_CONVERSION_KEEP_SOURCE:-1}" -eq 0 ]; then
find /watch/ -mindepth 1 -type d -empty -delete
fi
fi

sleep 5
Expand Down

0 comments on commit 0d19bab

Please sign in to comment.