Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Remove the old one if we found two same file handles.
Browse files Browse the repository at this point in the history
Somehow sometimes the binding.watch would return a handle that was
already taken by a live handler, I have no idea of why this happened,
but we simply remove the old one for now so we do not have to throw an
exception.
  • Loading branch information
zcbenz committed Dec 2, 2013
1 parent c527306 commit 7e10102
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class HandleWatcher extends EventEmitter
@handle = binding.watch(@path)
if handleWatchers.has(@handle)
troubleWatcher = handleWatchers.get(@handle)
throw new Error("The handle(#{@handle}) returned by watching #{@path} is the same with an already watched path(#{troubleWatcher.path})")
troubleWatcher.close()
console.error("The handle(#{@handle}) returned by watching #{@path} is the same with an already watched path(#{troubleWatcher.path})")
handleWatchers.add(@handle, this)

closeIfNoListener: ->
Expand Down

1 comment on commit 7e10102

@glasser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in this commit is broken. #98

Please sign in to comment.