Skip to content

Commit a439c21

Browse files
author
reddy.heo
committed
Fixed issue of re-reading rotated files
1 parent 7200a7a commit a439c21

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: lib/filewatch/sincedb_collection.rb

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def associate(watched_file)
8585
logger.trace? && logger.trace("associate: inode and path matched", :filename => watched_file.filename)
8686
return true
8787
end
88+
if watched_file.path.start_with?(sincedb_value.path_in_sincedb)
89+
# If the path starts with sincedb path, it is considered a rotated file.
90+
handle_association(sincedb_value, watched_file)
91+
logger.trace? && logger.trace("associate: matched but start with same name", :filename => watched_file.filename)
92+
return true
93+
end
8894
# the path on disk is different from discovered unassociated path but they have the same key (inode)
8995
# treat as a new file, a new value will be added when the file is opened
9096
sincedb_value.clear_watched_file

0 commit comments

Comments
 (0)