From 29ad083f253b0ca297006e71618c2325f766baa1 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 4 May 2018 14:11:20 -0700 Subject: [PATCH] Track Realms seen in the notifier by id rather than path If a Realm is deleted and then a new one is created at the same path it needs to be treated as a new Realm. --- lib/notifier.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/notifier.js b/lib/notifier.js index 0add6bf6..0e8c6cf4 100644 --- a/lib/notifier.js +++ b/lib/notifier.js @@ -45,11 +45,11 @@ class FunctionListener { return this.regexStr === regex && this.event === event && this.fn === fn; } - onavailable(path) { + onavailable(path, id) { if (this.regex.test(path)) { - if (this.event === 'available' && !this.seen[path]) { + if (this.event === 'available' && !this.seen[id]) { this.fn(path); - this.seen[path] = true; + this.seen[id] = true; } return this.event === 'change'; } @@ -103,11 +103,11 @@ class OutOfProcListener { return this.regexStr === regex && this.worker === worker; } - onavailable(path) { + onavailable(path, id) { if (this.regex.test(path)) { - if (!this.seen[path]) { + if (!this.seen[id]) { this.worker.onavailable(path); - this.seen[path] = true; + this.seen[id] = true; } return true; } @@ -161,10 +161,11 @@ class Listener { changes.release(); } - available(virtualPath) { + available(virtualPath, id) { let watch = false; + id = id || virtualPath; for (const callback of this.callbacks) { - if (callback.onavailable(virtualPath)) { + if (callback.onavailable(virtualPath, id)) { watch = true; } }