Skip to content

Commit 1040ca2

Browse files
Filter out unwatchable roots early in FSWatchingLocator.initWatchers().
1 parent 8f95844 commit 1040ca2

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

‎src/client/pythonEnvironments/base/locators/lowLevel/fsWatchingLocator.ts‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ export abstract class FSWatchingLocator extends LazyResourceBasedLocator {
9292
if (typeof roots === 'string') {
9393
roots = [roots];
9494
}
95+
const promises = roots.map(async (root) => {
96+
// Note that we only check the root dir. Any directories
97+
// that might be watched due to a glob are not checked.
98+
const unwatchable = await checkDirWatchable(root);
99+
if (unwatchable) {
100+
logError(`dir "${root}" is not watchable (${unwatchable})`);
101+
return undefined;
102+
}
103+
return root;
104+
});
105+
const watchableRoots = (await Promise.all(promises)).filter((root) => !!root) as string[];
95106

96107
// Enable all workspace watchers.
97108
if (this.watcherKind === FSWatcherKind.Global) {
@@ -102,16 +113,7 @@ export abstract class FSWatchingLocator extends LazyResourceBasedLocator {
102113
}
103114
}
104115

105-
roots.forEach((root) => {
106-
// Note that we only check the root dir. Any directories
107-
// that might be watched due to a glob are not checked.
108-
const unwatchable = checkDirWatchable(root);
109-
if (unwatchable) {
110-
logError(`dir "${root}" is not watchable (${unwatchable})`);
111-
} else {
112-
this.startWatchers(root);
113-
}
114-
});
116+
watchableRoots.forEach((root) => this.startWatchers(root));
115117
}
116118

117119
private startWatchers(root: string): void {

0 commit comments

Comments
 (0)