From 55f190713a1931aca1241f0aa5608adf6ac4a361 Mon Sep 17 00:00:00 2001 From: Maximilian Frank Date: Fri, 26 Mar 2021 10:53:18 +0100 Subject: [PATCH] Mark in-active files as fully read before skipping them --- lib/filewatch/read_mode/processor.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/filewatch/read_mode/processor.rb b/lib/filewatch/read_mode/processor.rb index 09ee7025..4b77e763 100644 --- a/lib/filewatch/read_mode/processor.rb +++ b/lib/filewatch/read_mode/processor.rb @@ -71,7 +71,14 @@ def process_active(watched_files) logger.trace(__method__.to_s) # Handles watched_files in the active state. watched_files.each do |watched_file| - next unless watched_file.active? + unless watched_file.active? + if @settings.exit_after_read and watched_file.all_read? + # in-active files that have been read completly in a previous run + # need to be marked as such or the pipeline will not end + common_detach_when_allread(watched_file) + end + next + end begin restat(watched_file) @@ -99,7 +106,7 @@ def process_active(watched_files) def common_detach_when_allread(watched_file) watched_file.unwatch - watched_file.listener.reading_completed + watched_file.listener.reading_completed unless watched_file.listener.nil? add_deletable_path watched_file.path logger.trace? && logger.trace("whole file read, removing from collection", :path => watched_file.path) end