diff --git a/index.js b/index.js index 40f9c907..71259c04 100644 --- a/index.js +++ b/index.js @@ -34,6 +34,7 @@ const { REPLACER_RE, SLASH, + SLASH_SLASH, BRACE_START, BANG, ONE_DOT, @@ -96,11 +97,20 @@ const unifyPaths = (paths_) => { return paths.map(normalizePathToUnix); }; +// If SLASH_SLASH occurs at the beginning of path, it is not replaced +// because "//StoragePC/DrivePool/Movies" is a valid network path const toUnix = (string) => { let str = string.replace(BACK_SLASH_RE, SLASH); + let prepend = false; + if (str.startsWith(SLASH_SLASH)) { + prepend = true; + } while (str.match(DOUBLE_SLASH_RE)) { str = str.replace(DOUBLE_SLASH_RE, SLASH); } + if (prepend) { + str = SLASH + str; + } return str; }; diff --git a/lib/constants.js b/lib/constants.js index af358814..84c2d983 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -41,6 +41,7 @@ exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/; exports.REPLACER_RE = /^\.[/\\]/; exports.SLASH = '/'; +exports.SLASH_SLASH = '//'; exports.BRACE_START = '{'; exports.BANG = '!'; exports.ONE_DOT = '.'; diff --git a/lib/fsevents-handler.js b/lib/fsevents-handler.js index 9e2fb15e..c5af1a1f 100644 --- a/lib/fsevents-handler.js +++ b/lib/fsevents-handler.js @@ -242,7 +242,6 @@ async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts try { const stats = await stat(path) if (this.fsw.closed) return; - if (this.fsw.closed) return; if (sameTypes(info, stats)) { this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts); } else {