Class: FileWatch::TailMode::Handlers::Delete
- Defined in:
- lib/filewatch/tail_mode/handlers/delete.rb
Constant Summary collapse
- DATA_LOSS_WARNING =
"watched file path was deleted or rotated before all content was read, if the file is found again it will be read from the last position"
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#handle, #initialize, #quit?, #update_existing_specifically
Constructor Details
This class inherits a constructor from FileWatch::TailMode::Handlers::Base
Instance Method Details
#handle_specifically(watched_file) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/filewatch/tail_mode/handlers/delete.rb', line 6 def handle_specifically(watched_file) # TODO consider trying to find the renamed file - it will have the same inode. # Needs a rotate scheme rename hint from user e.g. "<name>-YYYY-MM-DD-N.<ext>" or "<name>.<ext>.N" # send the found content to the same listener (stream identity) logger.trace? && logger.trace(__method__.to_s, :path => watched_file.path, :watched_file => watched_file.details) if watched_file.bytes_unread > 0 logger.warn(DATA_LOSS_WARNING, :path => watched_file.path, :unread_bytes => watched_file.bytes_unread) end watched_file.listener.deleted # no need to worry about data in the buffer # if found it will be associated by inode and read from last position sincedb_collection.watched_file_deleted(watched_file) watched_file.file_close end |