ffilewatch 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/filewatch/tail.rb +11 -10
- data/lib/filewatch/watch.rb +13 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 481083c53436c7285931f96e4635bb24a5c746a5
|
4
|
+
data.tar.gz: b181239c5ba187b531374dde0db12de41b0a95a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f41469d190c2553fdc6db47e0789a3913d8e08ef3a44deffcf8d6c9ca0bda77e8c67132602c2553db7bd3430a295a0387346115a4065e3861c886011ee3a71
|
7
|
+
data.tar.gz: 96dfba9b0d253e52cdd4bd628d9fcde353778665bb1a114b1ab7032077cbc30e581c1abbc74656268619c458771127b4e57f59acca6584de8511baf272c52e8c
|
data/lib/filewatch/tail.rb
CHANGED
@@ -22,7 +22,7 @@ module FileWatch
|
|
22
22
|
@logger = opts[:logger]
|
23
23
|
else
|
24
24
|
@logger = Logger.new(STDERR)
|
25
|
-
@logger.level = Logger::
|
25
|
+
@logger.level = Logger::DEBUG
|
26
26
|
end
|
27
27
|
@evict = nil
|
28
28
|
@files = {}
|
@@ -52,8 +52,9 @@ module FileWatch
|
|
52
52
|
if !@opts.include?(:sincedb_path)
|
53
53
|
raise NoSinceDBPathGiven.new("No HOME or SINCEDB_PATH set in environment. I need one of these set so I can keep track of the files I am following.")
|
54
54
|
end
|
55
|
-
@watch = FileWatch::Watch.new
|
56
|
-
|
55
|
+
@watch = FileWatch::Watch.new \
|
56
|
+
logger: @opts[:logger],
|
57
|
+
ignore_before: @opts[:ignore_before]
|
57
58
|
@watch.exclude(@opts[:exclude])
|
58
59
|
_start_eviction
|
59
60
|
_sincedb_open
|
@@ -151,9 +152,9 @@ module FileWatch
|
|
151
152
|
|
152
153
|
if @sincedb.member?(inode)
|
153
154
|
last_size = @sincedb[inode]
|
154
|
-
@logger.debug("#{path}: sincedb last value #{@sincedb[inode]}, cur size #{stat.size}")
|
155
|
+
# @logger.debug("#{path}: sincedb last value #{@sincedb[inode]}, cur size #{stat.size}")
|
155
156
|
if last_size <= stat.size
|
156
|
-
@logger.debug("#{path}: sincedb: seeking to #{last_size}")
|
157
|
+
# @logger.debug("#{path}: sincedb: seeking to #{last_size}")
|
157
158
|
@files[path].sysseek(last_size, IO::SEEK_SET)
|
158
159
|
else
|
159
160
|
@logger.debug("#{path}: last value size is greater than current value, starting over")
|
@@ -162,17 +163,17 @@ module FileWatch
|
|
162
163
|
elsif event == :create_initial && @files[path]
|
163
164
|
# TODO(sissel): Allow starting at beginning of the file.
|
164
165
|
if @opts[:start_new_files_at] == :beginning
|
165
|
-
@logger.debug("#{path}: initial create, no sincedb, seeking to beginning of file")
|
166
|
+
# @logger.debug("#{path}: initial create, no sincedb, seeking to beginning of file")
|
166
167
|
@files[path].sysseek(0, IO::SEEK_SET)
|
167
168
|
@sincedb[inode] = 0
|
168
169
|
else
|
169
170
|
# seek to end
|
170
|
-
@logger.debug("#{path}: initial create, no sincedb, seeking to end #{stat.size}")
|
171
|
+
# @logger.debug("#{path}: initial create, no sincedb, seeking to end #{stat.size}")
|
171
172
|
@files[path].sysseek(stat.size, IO::SEEK_SET)
|
172
173
|
@sincedb[inode] = stat.size
|
173
174
|
end
|
174
175
|
else
|
175
|
-
@logger.debug("#{path}: staying at position 0, no sincedb")
|
176
|
+
# @logger.debug("#{path}: staying at position 0, no sincedb")
|
176
177
|
end
|
177
178
|
@changed[path] = Time.now.to_i
|
178
179
|
@locked[path] = false
|
@@ -229,7 +230,7 @@ module FileWatch
|
|
229
230
|
db.each do |line|
|
230
231
|
ino, dev_major, dev_minor, pos = line.split("*", 4)
|
231
232
|
inode = [ino, dev_major.to_i, dev_minor.to_i]
|
232
|
-
@logger.debug("_sincedb_open: setting #{inode.inspect} to #{pos.to_i}")
|
233
|
+
# @logger.debug("_sincedb_open: setting #{inode.inspect} to #{pos.to_i}")
|
233
234
|
@sincedb[inode] = pos.to_i
|
234
235
|
end
|
235
236
|
db.close
|
@@ -274,7 +275,7 @@ module FileWatch
|
|
274
275
|
end
|
275
276
|
end
|
276
277
|
|
277
|
-
@logger.debug("writing sincedb (delta since last write = #{delta})")
|
278
|
+
# @logger.debug("writing sincedb (delta since last write = #{delta})")
|
278
279
|
|
279
280
|
path = @opts[:sincedb_path]
|
280
281
|
tmp = "#{path}.new"
|
data/lib/filewatch/watch.rb
CHANGED
@@ -18,7 +18,7 @@ module FileWatch
|
|
18
18
|
@logger = opts[:logger]
|
19
19
|
else
|
20
20
|
@logger = Logger.new(STDERR)
|
21
|
-
@logger.level = Logger::
|
21
|
+
@logger.level = Logger::DEBUG
|
22
22
|
end
|
23
23
|
@watching = []
|
24
24
|
@exclude = []
|
@@ -92,7 +92,7 @@ module FileWatch
|
|
92
92
|
yield(:delete, real(path))
|
93
93
|
yield(:create, real(path))
|
94
94
|
elsif stat.size > @files[path][:size]
|
95
|
-
@logger.debug("#{path}: file grew, old size #{@files[path][:size]}, new size #{stat.size}")
|
95
|
+
# @logger.debug("#{path}: file grew, old size #{@files[path][:size]}, new size #{stat.size}")
|
96
96
|
yield(:modify, real(path))
|
97
97
|
else
|
98
98
|
# since there is no update, we should pass control back in case the caller needs to do any work
|
@@ -145,22 +145,27 @@ module FileWatch
|
|
145
145
|
next if @files.member?(file)
|
146
146
|
next unless File.file?(file)
|
147
147
|
|
148
|
-
@logger.debug("_discover_file: #{path}: new: #{file} (exclude is #{@exclude.inspect})")
|
149
|
-
|
150
148
|
skip = false
|
151
149
|
@exclude.each do |pattern|
|
152
150
|
if File.fnmatch?(pattern, File.basename(file))
|
153
|
-
@logger.debug("_discover_file: #{file}: skipping because it " +
|
154
|
-
|
151
|
+
# @logger.debug("_discover_file: #{file}: skipping because it " +
|
152
|
+
# "matches exclude #{pattern}")
|
155
153
|
skip = true
|
156
154
|
break
|
157
155
|
end
|
158
156
|
end
|
159
157
|
next if skip
|
160
158
|
|
161
|
-
next if File::mtime(file).to_i < @opts[:ignore_before]
|
162
|
-
|
163
159
|
stat = File::Stat.new(file)
|
160
|
+
|
161
|
+
if stat.mtime.to_i < @opts[:ignore_before]
|
162
|
+
# @logger.debug("_discover_file: #{file}: skipping because it " +
|
163
|
+
# "was last modified before ignore_before")
|
164
|
+
next
|
165
|
+
end
|
166
|
+
|
167
|
+
@logger.debug("_discover_file: #{path}: new: #{file} (exclude is #{@exclude.inspect})")
|
168
|
+
|
164
169
|
@files[file] = {
|
165
170
|
:size => 0,
|
166
171
|
:inode => [stat.ino, stat.dev_major, stat.dev_minor],
|