Commit 4e887c41 authored by Leo Iannacone's avatar Leo Iannacone

again back on JS for tail patch

parent 53054ab6
...@@ -105,17 +105,25 @@ errors_handler = (from, err, socket) -> ...@@ -105,17 +105,25 @@ errors_handler = (from, err, socket) ->
return return
Tail::watchEvent = (e) -> Tail::watchEvent = (e) ->
if e is 'change' _this = this
fs.stat @filename, (err, stats) => if e is "change"
@emit 'error', err if err fs.stat @filename, (err, stats) ->
@pos = stats.size if stats.size < @pos #scenario where texts is not appended but it's actually a w+ if err
if stats.size > @pos _this.emit "error", err
@queue.push({start: @pos, end: stats.size}) return
@pos = stats.size _this.pos = stats.size if stats.size < _this.pos
@internalDispatcher.emit("next") if @queue.length is 1 if stats.size > _this.pos
else if e is 'rename' _this.queue.push
@unwatch() start: _this.pos
@emit "error", "File #{@filename} deleted" end: stats.size
_this.pos = stats.size
_this.internalDispatcher.emit "next" if _this.queue.length is 1
else if e is "rename"
@unwatch()
_this.emit "error", "File " + @filename + " deleted."
return
Tail::close = -> Tail::close = ->
@unwatch() @unwatch()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment