Skip to content

Commit

Permalink
Fixed issue of re-reading rotated files
Browse files Browse the repository at this point in the history
  • Loading branch information
reddy.heo committed Sep 17, 2021
1 parent 7200a7a commit 5040fab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/filewatch/sincedb_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ def associate(watched_file)
logger.trace? && logger.trace("associate: inode and path matched", :filename => watched_file.filename)
return true
end
if watched_file.path.start_with?(sincedb_value.path_in_sincedb)
# If the path starts with sincedb path, it is considered a rotated file.
handle_association(sincedb_value, watched_file)
logger.trace? && logger.trace("associate: matched but start with same path", :filename => watched_file.filename)
return true
end
# the path on disk is different from discovered unassociated path but they have the same key (inode)
# treat as a new file, a new value will be added when the file is opened
sincedb_value.clear_watched_file
Expand Down

0 comments on commit 5040fab

Please sign in to comment.