提交 de292c2f 编写于 作者: I isidor

fallback to stat if lstat fails

#44543
上级 52659445
......@@ -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 });
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册