From de292c2ff7712772d3a0c2a4652dcda295ddb000 Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 27 Feb 2018 16:31:19 +0100 Subject: [PATCH] fallback to stat if lstat fails #44543 --- src/vs/base/node/extfs.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/vs/base/node/extfs.ts b/src/vs/base/node/extfs.ts index 18400de99ee..82a1038af22 100644 --- a/src/vs/base/node/extfs.ts +++ b/src/vs/base/node/extfs.ts @@ -49,21 +49,17 @@ export interface IStatAndLink { } export function statLink(path: string, callback: (error: Error, statAndIsLink: IStatAndLink) => void): void { - fs.lstat(path, (error, stat) => { - if (error) { - return callback(error, null); - } - - if (stat.isSymbolicLink()) { + fs.lstat(path, (error, lstat) => { + if (error || lstat.isSymbolicLink()) { fs.stat(path, (error, stat) => { if (error) { return callback(error, null); } - callback(null, { stat, isSymbolicLink: true }); + callback(null, { stat, isSymbolicLink: lstat && lstat.isSymbolicLink() }); }); } else { - callback(null, { stat, isSymbolicLink: false }); + callback(null, { stat: lstat, isSymbolicLink: false }); } }); }