mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Don't rely on pathwatcher.watch to determine if files exist.
This commit is contained in:
@@ -407,33 +407,24 @@ _.extend(Watcher.prototype, {
|
||||
return;
|
||||
}
|
||||
|
||||
var onWatchEvent = self._makeWatchEventCallback(absPath);
|
||||
|
||||
if (self.justCheckOnce) {
|
||||
onWatchEvent();
|
||||
return;
|
||||
}
|
||||
self._makeWatchEventCallback(absPath)();
|
||||
|
||||
try {
|
||||
} else if (files.exists(absPath)) {
|
||||
var onWatchEvent = self._makeWatchEventCallback(absPath);
|
||||
entry.watcher = pathwatcher.watch(absPath, onWatchEvent);
|
||||
|
||||
} catch (err) {
|
||||
if (err.code === "ENOENT" || // For fs.watch.
|
||||
(err instanceof TypeError && // For pathwatcher.watch.
|
||||
err.message === "Unable to watch path")) {
|
||||
var parentDir = files.pathDirname(absPath);
|
||||
if (parentDir !== absPath) {
|
||||
self._watchFileOrDirectory(parentDir);
|
||||
}
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.watcher) {
|
||||
// If we successfully created the watcher, invoke the callback
|
||||
// immediately, so that we examine this file at least once.
|
||||
onWatchEvent();
|
||||
|
||||
} else {
|
||||
var parentDir = files.pathDirname(absPath);
|
||||
if (parentDir === absPath) {
|
||||
throw new Error("Unable to watch parent directory of " + absPath);
|
||||
}
|
||||
|
||||
self._watchFileOrDirectory(parentDir);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user