Class: FileWatch::TailMode::Handlers::CreateInitial

Inherits:
Base
  • Object
show all
Defined in:
lib/filewatch/tail_mode/handlers/create_initial.rb

Instance Attribute Summary

Attributes inherited from Base

#sincedb_collection

Instance Method Summary collapse

Methods inherited from Base

#handle, #initialize, #quit?

Constructor Details

This class inherits a constructor from FileWatch::TailMode::Handlers::Base

Instance Method Details

#handle_specifically(watched_file) ⇒ Object



5
6
7
8
9
10
# File 'lib/filewatch/tail_mode/handlers/create_initial.rb', line 5

def handle_specifically(watched_file)
  if open_file(watched_file)
    logger.trace("handle_specifically opened file handle: #{watched_file.file.fileno}, path: #{watched_file.filename}")
    add_or_update_sincedb_collection(watched_file)
  end
end

#update_existing_specifically(watched_file, sincedb_value) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/filewatch/tail_mode/handlers/create_initial.rb', line 12

def update_existing_specifically(watched_file, sincedb_value)
  position = watched_file.last_stat_size
  if @settings.start_new_files_at == :beginning
    position = 0
  end
  logger.trace("update_existing_specifically - #{watched_file.path}: seeking to #{position}")
  watched_file.update_bytes_read(position)
  sincedb_value.update_position(position)
end