Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue of re-reading rotated files #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 name", :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