Sha256: 2641f32495c5b8dfb3d35c2c3b51c17c21c217cf2358a7988fb9dd7bb6bfcd69

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

# encoding: utf-8

module FileWatch module TailMode module Handlers
  class Shrink < Base
    def handle_specifically(watched_file)
      add_or_update_sincedb_collection(watched_file)
      watched_file.file_seek(watched_file.bytes_read)
      loop do
        loop_control = watched_file.loop_control_adjusted_for_stat_size
        controlled_read(watched_file, loop_control)
        break unless loop_control.more
      end
    end

    def update_existing_specifically(watched_file, sincedb_value)
      # we have a match but size is smaller
      # set all to zero
      watched_file.reset_bytes_unread
      sincedb_value.update_position(0)
      logger.trace("update_existing_specifically: was truncated seeking to beginning", "watched file" => watched_file.details, "sincedb value" => sincedb_value)
    end
  end
end end end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-input-file-4.1.4 lib/filewatch/tail_mode/handlers/shrink.rb