Skip to content

Commit e4ce1b9

Browse files
committed
Avoid to seek to a position that was alread read in
1 parent c83b259 commit e4ce1b9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: lib/filewatch/read_mode/handlers/read_file.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ module FileWatch module ReadMode module Handlers
44
class ReadFile < Base
55
def handle_specifically(watched_file)
66
if open_file(watched_file)
7-
add_or_update_sincedb_collection(watched_file)
8-
watched_file.file_seek(watched_file.bytes_read)
7+
add_or_update_sincedb_collection(watched_file) unless sincedb_collection.member?(watched_file.sincedb_key)
8+
previous_pos = sincedb_collection.find(watched_file).position
9+
watched_file.file_seek([watched_file.bytes_read, previous_pos].max)
910
loop do
1011
break if quit?
1112
loop_control = watched_file.loop_control_adjusted_for_stat_size

0 commit comments

Comments
 (0)