From 7e1010222cd3946b6d3ed1516b708aa5603e60c3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 2 Dec 2013 23:38:01 +0800 Subject: [PATCH] Remove the old one if we found two same file handles. 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. --- src/main.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.coffee b/src/main.coffee index 7a1557e..a781d8e 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -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: ->