From 72fac739a31446ce1e0568291e6fe9a4f9d9388e Mon Sep 17 00:00:00 2001 From: Jocelyn Le Sage Date: Wed, 24 May 2017 13:05:04 -0400 Subject: [PATCH] Opened files on the host are not visible by lsof inside the docker. Instead, check that file properties remain stable for a specified amount of time. --- Dockerfile | 3 +-- README.md | 1 + rootfs/etc/services.d/watchfolder/run | 31 ++++++++++++++------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index e6b02cf..61f6fb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,8 +37,7 @@ RUN sed -i 's///dev/null; then - log "Skipping file '$file': currently being accessed." - # Invalidate the watch directory hash. If we don't, we may never - # process this file because the hash may remain the same. - WATCHDIR_HASH_invalidate - return - fi - - # Get hash of the file from its name, size and time. - hash="$(stat -c '%n %s %Y' "$file" | md5sum | cut -d' ' -f1)" + # Get hash of the file from its properties. + hash="$(get_hash "$file")" # Skip file if it has been already successfully processed. if grep -q -w "$hash" "$SUCCESSFUL_CONVERSIONS"; then @@ -70,6 +63,14 @@ process_file() { return fi + # Skip file if it is not stable. + echo "Waiting $AUTOMATED_CONVERSION_SOURCE_STABLE_TIME seconds before processing '$file'..." + sleep $AUTOMATED_CONVERSION_SOURCE_STABLE_TIME + if [ "$hash" != "$(get_hash "$file")" ]; then + log "Skipping file '$file': currently being copied." + return + fi + log "Starting conversion of '$file' ($hash)..." basename="$(basename "$file" | sed 's/\.[^.]*$//')" $HANDBRAKE_CLI -i "$file" \