Do not watch child directories of the sym link folders

Fixes #22668
This commit is contained in:
Sheetal Nandi
2018-03-28 18:37:07 -07:00
parent e40f2943b1
commit f885cd971e
3 changed files with 70 additions and 16 deletions

View File

@@ -337,6 +337,7 @@ namespace ts {
getAccessileSortedChildDirectories(path: string): ReadonlyArray<string>;
directoryExists(dir: string): boolean;
filePathComparer: Comparer<string>;
realpath(s: string): string;
}
/**
@@ -392,9 +393,12 @@ namespace ts {
function watchChildDirectories(parentDir: string, existingChildWatches: ChildWatches, callback: DirectoryWatcherCallback): ChildWatches {
let newChildWatches: DirectoryWatcher[] | undefined;
enumerateInsertsAndDeletes<string, DirectoryWatcher>(
host.directoryExists(parentDir) ? host.getAccessileSortedChildDirectories(parentDir) : emptyArray,
host.directoryExists(parentDir) ? mapDefined(host.getAccessileSortedChildDirectories(parentDir), child => {
const childFullName = getNormalizedAbsolutePath(child, parentDir);
return host.filePathComparer(childFullName, host.realpath(childFullName)) === Comparison.EqualTo ? childFullName : undefined;
}) : emptyArray,
existingChildWatches,
(child, childWatcher) => host.filePathComparer(getNormalizedAbsolutePath(child, parentDir), childWatcher.dirName),
(child, childWatcher) => host.filePathComparer(child, childWatcher.dirName),
createAndAddChildDirectoryWatcher,
closeFileWatcher,
addChildDirectoryWatcher
@@ -406,7 +410,7 @@ namespace ts {
* Create new childDirectoryWatcher and add it to the new ChildDirectoryWatcher list
*/
function createAndAddChildDirectoryWatcher(childName: string) {
const result = createDirectoryWatcher(getNormalizedAbsolutePath(childName, parentDir), callback);
const result = createDirectoryWatcher(childName, callback);
addChildDirectoryWatcher(result);
}
@@ -601,14 +605,7 @@ namespace ts {
exit(exitCode?: number): void {
process.exit(exitCode);
},
realpath(path: string): string {
try {
return _fs.realpathSync(path);
}
catch {
return path;
}
},
realpath,
debugMode: some(<string[]>process.execArgv, arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)),
tryEnableSourceMapsForHost() {
try {
@@ -700,7 +697,8 @@ namespace ts {
filePathComparer: useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive,
directoryExists,
getAccessileSortedChildDirectories: path => getAccessibleFileSystemEntries(path).directories,
watchDirectory
watchDirectory,
realpath
});
return (directoryName, callback, recursive) => {
@@ -1043,6 +1041,15 @@ namespace ts {
return filter<string>(_fs.readdirSync(path), dir => fileSystemEntryExists(combinePaths(path, dir), FileSystemEntryKind.Directory));
}
function realpath(path: string): string {
try {
return _fs.realpathSync(path);
}
catch {
return path;
}
}
function getModifiedTime(path: string) {
try {
return _fs.statSync(path).mtime;