better fix for #44543

This commit is contained in:
Benjamin Pasero 2018-02-27 16:03:29 +01:00
parent 1a8ff9edff
commit 4d6291cd4a
2 changed files with 11 additions and 12 deletions

View file

@ -43,7 +43,12 @@ export function readdir(path: string, callback: (error: Error, files: string[])
return fs.readdir(path, callback);
}
export function statLink(path: string, callback: (error: Error, statAndIsLink: { stat: fs.Stats, isSymbolicLink: boolean }) => void): void {
export interface IStatAndLink {
stat: fs.Stats;
isSymbolicLink: boolean;
}
export function statLink(path: string, callback: (error: Error, statAndIsLink: IStatAndLink) => void): void {
fs.lstat(path, (error, stat) => {
if (error) {
return callback(error, null);

View file

@ -42,7 +42,7 @@ import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/
import { getBaseLabel } from 'vs/base/common/labels';
import { assign } from 'vs/base/common/objects';
import { Readable } from 'stream';
import { IWriteFileOptions } from 'vs/base/node/extfs';
import { IWriteFileOptions, IStatAndLink } from 'vs/base/node/extfs';
import { Schemas } from 'vs/base/common/network';
export interface IEncodingOverride {
@ -1233,18 +1233,12 @@ export class StatResolver {
},
function stat(this: any): void {
extfs.statLink(fileResource.fsPath, (error: Error, statAndIsLink) => {
if (error) {
return this(error, null);
}
isSymbolicLink = statAndIsLink.isSymbolicLink;
this(null, statAndIsLink.stat);
});
extfs.statLink(fileResource.fsPath, this);
},
function countChildren(this: any, fsstat: fs.Stats): void {
fileStat = fsstat;
function countChildren(this: any, statAndLink: IStatAndLink): void {
fileStat = statAndLink.stat;
isSymbolicLink = statAndLink.isSymbolicLink;
if (fileStat.isDirectory()) {
extfs.readdir(fileResource.fsPath, (error, result) => {