logstash-input-file 4.1.18 → 4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/lib/filewatch/discoverer.rb +9 -8
- data/lib/filewatch/observing_base.rb +1 -12
- data/lib/filewatch/processor.rb +55 -0
- data/lib/filewatch/read_mode/handlers/base.rb +12 -11
- data/lib/filewatch/read_mode/handlers/read_file.rb +23 -8
- data/lib/filewatch/read_mode/handlers/read_zip_file.rb +8 -6
- data/lib/filewatch/read_mode/processor.rb +22 -36
- data/lib/filewatch/settings.rb +1 -2
- data/lib/filewatch/sincedb_collection.rb +40 -41
- data/lib/filewatch/sincedb_record_serializer.rb +5 -11
- data/lib/filewatch/stat/generic.rb +8 -13
- data/lib/filewatch/stat/windows_path.rb +7 -9
- data/lib/filewatch/tail_mode/handlers/base.rb +32 -23
- data/lib/filewatch/tail_mode/handlers/delete.rb +2 -4
- data/lib/filewatch/tail_mode/handlers/shrink.rb +2 -3
- data/lib/filewatch/tail_mode/handlers/unignore.rb +4 -4
- data/lib/filewatch/tail_mode/processor.rb +47 -54
- data/lib/filewatch/watch.rb +12 -14
- data/lib/filewatch/watched_file.rb +25 -14
- data/lib/filewatch/watched_files_collection.rb +11 -78
- data/lib/jars/filewatch-1.0.1.jar +0 -0
- data/lib/logstash/inputs/file.rb +4 -3
- data/lib/logstash/inputs/file_listener.rb +3 -14
- data/logstash-input-file.gemspec +2 -1
- data/spec/filewatch/reading_spec.rb +63 -12
- data/spec/filewatch/rotate_spec.rb +4 -4
- data/spec/filewatch/settings_spec.rb +3 -0
- data/spec/filewatch/sincedb_record_serializer_spec.rb +6 -2
- data/spec/filewatch/spec_helper.rb +12 -14
- data/spec/filewatch/tailing_spec.rb +24 -22
- data/spec/filewatch/watched_file_spec.rb +30 -0
- data/spec/filewatch/watched_files_collection_spec.rb +62 -8
- data/spec/inputs/file_read_spec.rb +58 -14
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2970d560b9e8225f4836f8ac751d3502298b8138a59b39945bc037d62b8edfd7
|
4
|
+
data.tar.gz: 0e3dd6f277a11acc12e5e02e3eab368dbe4c180b1bb7598dbc221cd5fc0a6cea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 792cc9de537e342df689c920419a036689f8ecee9ea015ab37ae0838925dc23872fa4b168a9210f768145d917d1bff39e8d6a718bb66afce37a54205aff02e9f
|
7
|
+
data.tar.gz: f94e97ec177e42289b4d651bc32ee8079ca2f4c5146db88cf0921a6a61ae8729e9a2502035a7a6f0042b657449b488cde7c826a988ad512b4736f0b5a669dd4b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 4.2.4
|
2
|
+
- Fix: sincedb_write issue on Windows machines [#283](https://github.com/logstash-plugins/logstash-input-file/pull/283)
|
3
|
+
|
4
|
+
## 4.2.3
|
5
|
+
- Refactor: improve debug logging (log catched exceptions) [#280](https://github.com/logstash-plugins/logstash-input-file/pull/280)
|
6
|
+
|
7
|
+
## 4.2.2
|
8
|
+
- Fix: sincedb_clean_after not being respected [#276](https://github.com/logstash-plugins/logstash-input-file/pull/276)
|
9
|
+
|
10
|
+
## 4.2.1
|
11
|
+
- Fix: skip sincedb eviction if read mode completion deletes file during flush [#273](https://github.com/logstash-plugins/logstash-input-file/pull/273)
|
12
|
+
|
13
|
+
## 4.2.0
|
14
|
+
- Fix: watched files performance with huge filesets [#268](https://github.com/logstash-plugins/logstash-input-file/pull/268)
|
15
|
+
- Updated logging to include full traces in debug (and trace) levels
|
16
|
+
|
1
17
|
## 4.1.18
|
2
18
|
- Fix: release watched files on completion (in read-mode) [#271](https://github.com/logstash-plugins/logstash-input-file/pull/271)
|
3
19
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
Travis Build
|
3
|
-
[![Travis Build Status](https://travis-ci.
|
3
|
+
[![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-input-file.svg)](https://travis-ci.com/logstash-plugins/logstash-input-file)
|
4
4
|
|
5
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
6
|
|
data/lib/filewatch/discoverer.rb
CHANGED
@@ -9,6 +9,8 @@ module FileWatch
|
|
9
9
|
# associated with a sincedb entry if one can be found
|
10
10
|
include LogStash::Util::Loggable
|
11
11
|
|
12
|
+
attr_reader :watched_files_collection
|
13
|
+
|
12
14
|
def initialize(watched_files_collection, sincedb_collection, settings)
|
13
15
|
@watching = Concurrent::Array.new
|
14
16
|
@exclude = Concurrent::Array.new
|
@@ -37,8 +39,7 @@ module FileWatch
|
|
37
39
|
@exclude.each do |pattern|
|
38
40
|
if watched_file.pathname.basename.fnmatch?(pattern)
|
39
41
|
if new_discovery
|
40
|
-
logger.trace("
|
41
|
-
"because it matches exclude #{pattern}")
|
42
|
+
logger.trace("skipping file because it matches exclude", :path => watched_file.path, :pattern => pattern)
|
42
43
|
end
|
43
44
|
watched_file.unwatch
|
44
45
|
return true
|
@@ -56,13 +57,13 @@ module FileWatch
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def discover_any_files(path, ongoing)
|
59
|
-
fileset = Dir.glob(path).select{|f| File.file?(f)}
|
60
|
-
logger.trace("discover_files",
|
60
|
+
fileset = Dir.glob(path).select { |f| File.file?(f) }
|
61
|
+
logger.trace("discover_files", :count => fileset.size)
|
61
62
|
fileset.each do |file|
|
62
|
-
pathname = Pathname.new(file)
|
63
63
|
new_discovery = false
|
64
|
-
watched_file = @watched_files_collection.
|
64
|
+
watched_file = @watched_files_collection.get(file)
|
65
65
|
if watched_file.nil?
|
66
|
+
pathname = Pathname.new(file)
|
66
67
|
begin
|
67
68
|
path_stat = PathStatClass.new(pathname)
|
68
69
|
rescue Errno::ENOENT
|
@@ -74,7 +75,7 @@ module FileWatch
|
|
74
75
|
# if it already unwatched or its excluded then we can skip
|
75
76
|
next if watched_file.unwatched? || can_exclude?(watched_file, new_discovery)
|
76
77
|
|
77
|
-
logger.trace("
|
78
|
+
logger.trace? && logger.trace("handling:", :new_discovery => new_discovery, :watched_file => watched_file.details)
|
78
79
|
|
79
80
|
if new_discovery
|
80
81
|
watched_file.initial_completed if ongoing
|
@@ -86,7 +87,7 @@ module FileWatch
|
|
86
87
|
# associated with a different watched_file
|
87
88
|
if @sincedb_collection.associate(watched_file)
|
88
89
|
if watched_file.file_ignorable?
|
89
|
-
logger.trace("
|
90
|
+
logger.trace("skipping file because it was last modified more than #{@settings.ignore_older} seconds ago", :path => file)
|
90
91
|
# on discovery ignorable watched_files are put into the ignored state and that
|
91
92
|
# updates the size from the internal stat
|
92
93
|
# so the existing contents are not read.
|
@@ -62,8 +62,7 @@ module FileWatch
|
|
62
62
|
@sincedb_collection = SincedbCollection.new(@settings)
|
63
63
|
@sincedb_collection.open
|
64
64
|
discoverer = Discoverer.new(watched_files_collection, @sincedb_collection, @settings)
|
65
|
-
@watch = Watch.new(discoverer,
|
66
|
-
@watch.add_processor build_specific_processor(@settings)
|
65
|
+
@watch = Watch.new(discoverer, build_specific_processor(@settings), @settings)
|
67
66
|
end
|
68
67
|
|
69
68
|
def watch_this(path)
|
@@ -84,15 +83,5 @@ module FileWatch
|
|
84
83
|
# sincedb_write("shutting down")
|
85
84
|
end
|
86
85
|
|
87
|
-
# close_file(path) is to be used by external code
|
88
|
-
# when it knows that it is completely done with a file.
|
89
|
-
# Other files or folders may still be being watched.
|
90
|
-
# Caution, once unwatched, a file can't be watched again
|
91
|
-
# unless a new instance of this class begins watching again.
|
92
|
-
# The sysadmin should rename, move or delete the file.
|
93
|
-
def close_file(path)
|
94
|
-
@watch.unwatch(path)
|
95
|
-
sincedb_write
|
96
|
-
end
|
97
86
|
end
|
98
87
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/util/loggable"
|
3
|
+
require 'concurrent/atomic/atomic_reference'
|
4
|
+
|
5
|
+
module FileWatch
|
6
|
+
class Processor
|
7
|
+
include LogStash::Util::Loggable
|
8
|
+
|
9
|
+
attr_reader :watch
|
10
|
+
|
11
|
+
def initialize(settings)
|
12
|
+
@settings = settings
|
13
|
+
@deletable_paths = Concurrent::AtomicReference.new []
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_watch(watch)
|
17
|
+
@watch = watch
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def clear_deletable_paths
|
22
|
+
@deletable_paths.get_and_set []
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_deletable_path(path)
|
26
|
+
@deletable_paths.get << path
|
27
|
+
end
|
28
|
+
|
29
|
+
def restat(watched_file)
|
30
|
+
changed = watched_file.restat!
|
31
|
+
if changed
|
32
|
+
# the collection (when sorted by modified_at) needs to re-sort every time watched-file is modified,
|
33
|
+
# we can perform these update operation while processing files (stat interval) instead of having to
|
34
|
+
# re-sort the whole collection every time an entry is accessed
|
35
|
+
@watch.watched_files_collection.update(watched_file)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def error_details(error, watched_file)
|
42
|
+
details = { :path => watched_file.path,
|
43
|
+
:exception => error.class,
|
44
|
+
:message => error.message,
|
45
|
+
:backtrace => error.backtrace }
|
46
|
+
if logger.debug?
|
47
|
+
details[:file] = watched_file
|
48
|
+
else
|
49
|
+
details[:backtrace] = details[:backtrace].take(8) if details[:backtrace]
|
50
|
+
end
|
51
|
+
details
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -19,7 +19,7 @@ module FileWatch module ReadMode module Handlers
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def handle(watched_file)
|
22
|
-
logger.trace("handling:
|
22
|
+
logger.trace? && logger.trace("handling:", :path => watched_file.path)
|
23
23
|
unless watched_file.has_listener?
|
24
24
|
watched_file.set_listener(@observer)
|
25
25
|
end
|
@@ -34,19 +34,21 @@ module FileWatch module ReadMode module Handlers
|
|
34
34
|
|
35
35
|
def open_file(watched_file)
|
36
36
|
return true if watched_file.file_open?
|
37
|
-
logger.trace("opening
|
37
|
+
logger.trace? && logger.trace("opening", :path => watched_file.path)
|
38
38
|
begin
|
39
39
|
watched_file.open
|
40
|
-
rescue
|
40
|
+
rescue => e
|
41
41
|
# don't emit this message too often. if a file that we can't
|
42
42
|
# read is changing a lot, we'll try to open it more often, and spam the logs.
|
43
43
|
now = Time.now.to_i
|
44
|
-
logger.trace("opening OPEN_WARN_INTERVAL is '#{OPEN_WARN_INTERVAL}'")
|
44
|
+
logger.trace? && logger.trace("opening OPEN_WARN_INTERVAL is '#{OPEN_WARN_INTERVAL}'")
|
45
45
|
if watched_file.last_open_warning_at.nil? || now - watched_file.last_open_warning_at > OPEN_WARN_INTERVAL
|
46
|
-
|
46
|
+
backtrace = e.backtrace
|
47
|
+
backtrace = backtrace.take(3) if backtrace && !logger.debug?
|
48
|
+
logger.warn("failed to open", :path => watched_file.path, :exception => e.class, :message => e.message, :backtrace => backtrace)
|
47
49
|
watched_file.last_open_warning_at = now
|
48
50
|
else
|
49
|
-
logger.trace("suppressed warning
|
51
|
+
logger.trace? && logger.trace("suppressed warning (failed to open)", :path => watched_file.path, :exception => e.class, :message => e.message)
|
50
52
|
end
|
51
53
|
watched_file.watch # set it back to watch so we can try it again
|
52
54
|
end
|
@@ -65,8 +67,7 @@ module FileWatch module ReadMode module Handlers
|
|
65
67
|
elsif sincedb_value.watched_file == watched_file
|
66
68
|
update_existing_sincedb_collection_value(watched_file, sincedb_value)
|
67
69
|
else
|
68
|
-
|
69
|
-
logger.trace(msg)
|
70
|
+
logger.trace? && logger.trace("add_or_update_sincedb_collection: the found sincedb_value has a watched_file - this is a rename, switching inode to this watched file")
|
70
71
|
existing_watched_file = sincedb_value.watched_file
|
71
72
|
if existing_watched_file.nil?
|
72
73
|
sincedb_value.set_watched_file(watched_file)
|
@@ -75,7 +76,7 @@ module FileWatch module ReadMode module Handlers
|
|
75
76
|
watched_file.update_bytes_read(sincedb_value.position)
|
76
77
|
else
|
77
78
|
sincedb_value.set_watched_file(watched_file)
|
78
|
-
logger.trace("add_or_update_sincedb_collection: switching from
|
79
|
+
logger.trace? && logger.trace("add_or_update_sincedb_collection: switching from", :watched_file => watched_file.details)
|
79
80
|
watched_file.rotate_from(existing_watched_file)
|
80
81
|
end
|
81
82
|
|
@@ -84,7 +85,7 @@ module FileWatch module ReadMode module Handlers
|
|
84
85
|
end
|
85
86
|
|
86
87
|
def update_existing_sincedb_collection_value(watched_file, sincedb_value)
|
87
|
-
logger.trace("update_existing_sincedb_collection_value: #{watched_file.path}, last value #{sincedb_value.position}, cur size #{watched_file.last_stat_size}")
|
88
|
+
logger.trace? && logger.trace("update_existing_sincedb_collection_value: #{watched_file.path}, last value #{sincedb_value.position}, cur size #{watched_file.last_stat_size}")
|
88
89
|
# sincedb_value is the source of truth
|
89
90
|
watched_file.update_bytes_read(sincedb_value.position)
|
90
91
|
end
|
@@ -92,7 +93,7 @@ module FileWatch module ReadMode module Handlers
|
|
92
93
|
def add_new_value_sincedb_collection(watched_file)
|
93
94
|
sincedb_value = SincedbValue.new(0)
|
94
95
|
sincedb_value.set_watched_file(watched_file)
|
95
|
-
logger.trace("add_new_value_sincedb_collection:
|
96
|
+
logger.trace? && logger.trace("add_new_value_sincedb_collection:", :path => watched_file.path, :position => sincedb_value.position)
|
96
97
|
sincedb_collection.set(watched_file.sincedb_key, sincedb_value)
|
97
98
|
end
|
98
99
|
end
|
@@ -19,8 +19,10 @@ module FileWatch module ReadMode module Handlers
|
|
19
19
|
watched_file.listener.eof
|
20
20
|
watched_file.file_close
|
21
21
|
key = watched_file.sincedb_key
|
22
|
-
sincedb_collection.
|
23
|
-
|
22
|
+
if sincedb_collection.get(key)
|
23
|
+
sincedb_collection.reading_completed(key)
|
24
|
+
sincedb_collection.clear_watched_file(key)
|
25
|
+
end
|
24
26
|
watched_file.listener.deleted
|
25
27
|
# NOTE: on top of un-watching we should also remove from the watched files collection
|
26
28
|
# if the file is getting deleted (on completion), that part currently resides in
|
@@ -31,7 +33,7 @@ module FileWatch module ReadMode module Handlers
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def controlled_read(watched_file, loop_control)
|
34
|
-
logger.trace("reading...",
|
36
|
+
logger.trace? && logger.trace("reading...", :filename => watched_file.filename, :iterations => loop_control.count, :amount => loop_control.size)
|
35
37
|
loop_control.count.times do
|
36
38
|
break if quit?
|
37
39
|
begin
|
@@ -43,22 +45,35 @@ module FileWatch module ReadMode module Handlers
|
|
43
45
|
delta = line.bytesize + @settings.delimiter_byte_size
|
44
46
|
sincedb_collection.increment(watched_file.sincedb_key, delta)
|
45
47
|
end
|
46
|
-
rescue EOFError
|
47
|
-
|
48
|
+
rescue EOFError => e
|
49
|
+
log_error("controlled_read: eof error reading file", watched_file, e)
|
48
50
|
loop_control.flag_read_error
|
49
51
|
break
|
50
|
-
rescue Errno::EWOULDBLOCK, Errno::EINTR
|
51
|
-
|
52
|
+
rescue Errno::EWOULDBLOCK, Errno::EINTR => e
|
53
|
+
log_error("controlled_read: block or interrupt error reading file", watched_file, e)
|
52
54
|
watched_file.listener.error
|
53
55
|
loop_control.flag_read_error
|
54
56
|
break
|
55
57
|
rescue => e
|
56
|
-
|
58
|
+
log_error("controlled_read: general error reading file", watched_file, e)
|
57
59
|
watched_file.listener.error
|
58
60
|
loop_control.flag_read_error
|
59
61
|
break
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
65
|
+
|
66
|
+
def log_error(msg, watched_file, error)
|
67
|
+
details = { :path => watched_file.path,
|
68
|
+
:exception => error.class,
|
69
|
+
:message => error.message,
|
70
|
+
:backtrace => error.backtrace }
|
71
|
+
if logger.debug?
|
72
|
+
details[:file] = watched_file
|
73
|
+
else
|
74
|
+
details[:backtrace] = details[:backtrace].take(8) if details[:backtrace]
|
75
|
+
end
|
76
|
+
logger.error(msg, details)
|
77
|
+
end
|
63
78
|
end
|
64
79
|
end end end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'java'
|
3
|
-
java_import java.io.InputStream
|
4
|
-
java_import java.io.InputStreamReader
|
5
|
-
java_import java.io.FileInputStream
|
6
|
-
java_import java.io.BufferedReader
|
7
|
-
java_import java.util.zip.GZIPInputStream
|
8
|
-
java_import java.util.zip.ZipException
|
9
3
|
|
10
4
|
module FileWatch module ReadMode module Handlers
|
5
|
+
|
6
|
+
java_import java.io.InputStream
|
7
|
+
java_import java.io.InputStreamReader
|
8
|
+
java_import java.io.FileInputStream
|
9
|
+
java_import java.io.BufferedReader
|
10
|
+
java_import java.util.zip.GZIPInputStream
|
11
|
+
java_import java.util.zip.ZipException
|
12
|
+
|
11
13
|
class ReadZipFile < Base
|
12
14
|
def handle_specifically(watched_file)
|
13
15
|
add_or_update_sincedb_collection(watched_file) unless sincedb_collection.member?(watched_file.sincedb_key)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
|
2
|
+
require 'filewatch/processor'
|
4
3
|
require_relative "handlers/base"
|
5
4
|
require_relative "handlers/read_file"
|
6
5
|
require_relative "handlers/read_zip_file"
|
@@ -9,20 +8,7 @@ module FileWatch module ReadMode
|
|
9
8
|
# Must handle
|
10
9
|
# :read_file
|
11
10
|
# :read_zip_file
|
12
|
-
class Processor
|
13
|
-
include LogStash::Util::Loggable
|
14
|
-
|
15
|
-
attr_reader :watch, :deletable_filepaths
|
16
|
-
|
17
|
-
def initialize(settings)
|
18
|
-
@settings = settings
|
19
|
-
@deletable_filepaths = []
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_watch(watch)
|
23
|
-
@watch = watch
|
24
|
-
self
|
25
|
-
end
|
11
|
+
class Processor < FileWatch::Processor
|
26
12
|
|
27
13
|
def initialize_handlers(sincedb_collection, observer)
|
28
14
|
# we deviate from the tail mode handler initialization here
|
@@ -48,24 +34,23 @@ module FileWatch module ReadMode
|
|
48
34
|
private
|
49
35
|
|
50
36
|
def process_watched(watched_files)
|
51
|
-
logger.trace(
|
37
|
+
logger.trace(__method__.to_s)
|
52
38
|
# Handles watched_files in the watched state.
|
53
39
|
# for a slice of them:
|
54
40
|
# move to the active state
|
55
41
|
# should never have been active before
|
56
42
|
# how much of the max active window is available
|
57
|
-
to_take = @settings.max_active - watched_files.count{|wf| wf.active?}
|
43
|
+
to_take = @settings.max_active - watched_files.count { |wf| wf.active? }
|
58
44
|
if to_take > 0
|
59
|
-
watched_files.select
|
60
|
-
path = watched_file.path
|
45
|
+
watched_files.select(&:watched?).take(to_take).each do |watched_file|
|
61
46
|
begin
|
62
|
-
watched_file
|
47
|
+
restat(watched_file)
|
63
48
|
watched_file.activate
|
64
49
|
rescue Errno::ENOENT
|
65
|
-
common_deleted_reaction(watched_file,
|
50
|
+
common_deleted_reaction(watched_file, __method__)
|
66
51
|
next
|
67
52
|
rescue => e
|
68
|
-
common_error_reaction(
|
53
|
+
common_error_reaction(watched_file, e, __method__)
|
69
54
|
next
|
70
55
|
end
|
71
56
|
break if watch.quit?
|
@@ -74,7 +59,7 @@ module FileWatch module ReadMode
|
|
74
59
|
now = Time.now.to_i
|
75
60
|
if (now - watch.lastwarn_max_files) > MAX_FILES_WARN_INTERVAL
|
76
61
|
waiting = watched_files.size - @settings.max_active
|
77
|
-
logger.warn(@settings.max_warn_msg
|
62
|
+
logger.warn("#{@settings.max_warn_msg}, files yet to open: #{waiting}")
|
78
63
|
watch.lastwarn_max_files = now
|
79
64
|
end
|
80
65
|
end
|
@@ -83,17 +68,18 @@ module FileWatch module ReadMode
|
|
83
68
|
## TODO add process_rotation_in_progress
|
84
69
|
|
85
70
|
def process_active(watched_files)
|
86
|
-
logger.trace(
|
71
|
+
logger.trace(__method__.to_s)
|
87
72
|
# Handles watched_files in the active state.
|
88
|
-
watched_files.
|
89
|
-
|
73
|
+
watched_files.each do |watched_file|
|
74
|
+
next unless watched_file.active?
|
75
|
+
|
90
76
|
begin
|
91
|
-
watched_file
|
77
|
+
restat(watched_file)
|
92
78
|
rescue Errno::ENOENT
|
93
|
-
common_deleted_reaction(watched_file,
|
79
|
+
common_deleted_reaction(watched_file, __method__)
|
94
80
|
next
|
95
81
|
rescue => e
|
96
|
-
common_error_reaction(
|
82
|
+
common_error_reaction(watched_file, e, __method__)
|
97
83
|
next
|
98
84
|
end
|
99
85
|
break if watch.quit?
|
@@ -114,19 +100,19 @@ module FileWatch module ReadMode
|
|
114
100
|
def common_detach_when_allread(watched_file)
|
115
101
|
watched_file.unwatch
|
116
102
|
watched_file.listener.reading_completed
|
117
|
-
|
118
|
-
logger.trace("
|
103
|
+
add_deletable_path watched_file.path
|
104
|
+
logger.trace? && logger.trace("whole file read, removing from collection", :path => watched_file.path)
|
119
105
|
end
|
120
106
|
|
121
107
|
def common_deleted_reaction(watched_file, action)
|
122
108
|
# file has gone away or we can't read it anymore.
|
123
109
|
watched_file.unwatch
|
124
|
-
|
125
|
-
logger.trace("#{action} - stat failed
|
110
|
+
add_deletable_path watched_file.path
|
111
|
+
logger.trace? && logger.trace("#{action} - stat failed, removing from collection", :path => watched_file.path)
|
126
112
|
end
|
127
113
|
|
128
|
-
def common_error_reaction(
|
129
|
-
logger.error("#{action} - other error
|
114
|
+
def common_error_reaction(watched_file, error, action)
|
115
|
+
logger.error("#{action} - other error", error_details(error, watched_file))
|
130
116
|
end
|
131
117
|
end
|
132
118
|
end end
|