|
9 | 9 | import { MultiFileSystemWatcher } from "./multi-file-system-watcher"; |
10 | 10 | import { AppEventEmitter } from "../events"; |
11 | 11 | import { extLogger } from ".."; |
12 | | -import { lstat, pathExists } from "fs-extra"; |
13 | | -import { containsPath } from "../../pure/files"; |
| 12 | +import { lstat } from "fs-extra"; |
| 13 | +import { containsPath, isIOError } from "../../pure/files"; |
14 | 14 | import { getOnDiskWorkspaceFoldersObjects } from "./workspace-folders"; |
15 | 15 |
|
16 | 16 | interface PathData { |
@@ -140,13 +140,24 @@ export abstract class FilePathDiscovery<T extends PathData> extends Discovery { |
140 | 140 | } |
141 | 141 |
|
142 | 142 | private async handledChangedPath(path: string): Promise<boolean> { |
143 | | - if (!(await pathExists(path)) || !this.pathIsInWorkspace(path)) { |
144 | | - return this.handleRemovedPath(path); |
145 | | - } |
146 | | - if ((await lstat(path)).isDirectory()) { |
147 | | - return await this.handleChangedDirectory(path); |
| 143 | + try { |
| 144 | + // If the path is not in the workspace then we don't want to be |
| 145 | + // tracking or displaying it, so treat it as if it doesn't exist. |
| 146 | + if (!this.pathIsInWorkspace(path)) { |
| 147 | + return this.handleRemovedPath(path); |
| 148 | + } |
| 149 | + |
| 150 | + if ((await lstat(path)).isDirectory()) { |
| 151 | + return await this.handleChangedDirectory(path); |
| 152 | + } else { |
| 153 | + return this.handleChangedFile(path); |
| 154 | + } |
| 155 | + } catch (e) { |
| 156 | + if (isIOError(e) && e.code === "ENOENT") { |
| 157 | + return this.handleRemovedPath(path); |
| 158 | + } |
| 159 | + throw e; |
148 | 160 | } |
149 | | - return this.handleChangedFile(path); |
150 | 161 | } |
151 | 162 |
|
152 | 163 | private pathIsInWorkspace(path: string): boolean { |
|
0 commit comments