Method: FileWatch::SincedbValue#unset_watched_file

Defined in:
lib/filewatch/sincedb_value.rb

#unset_watched_fileObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/filewatch/sincedb_value.rb', line 75

def unset_watched_file
  # called in read mode only because we flushed any remaining bytes as a final line.
  # cache the position
  # we don't cache the path here because we know we are done with this file.
  # either due via the `delete` handling
  # or when read mode is done with a file.
  # in the case of `delete` if the file was renamed then @watched_file is the
  # watched_file of the previous path and the new path will be discovered and
  # it should have the same inode as before.
  # The key from the new watched_file should then locate this entry and we
  # can resume from the cached position
  return if @watched_file.nil?
  wf = @watched_file
  @watched_file = nil
  @position = wf.bytes_read
end