Check for symlinks for task process

Fixes #130863
This commit is contained in:
Alex Ross 2021-08-16 13:58:32 +02:00
parent a0afddd876
commit d00c6a45bc
No known key found for this signature in database
GPG key ID: 89DDDBA66CBA7840

View file

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as cp from 'child_process';
import { Stats } from 'fs';
import { IStringDictionary } from 'vs/base/common/collections';
import * as extpath from 'vs/base/common/extpath';
import { FileAccess } from 'vs/base/common/network';
@ -457,7 +458,16 @@ export namespace win32 {
async function fileExists(path: string): Promise<boolean> {
if (await pfs.Promises.exists(path)) {
return !((await pfs.Promises.stat(path)).isDirectory());
let statValue: Stats | undefined;
try {
statValue = await pfs.Promises.stat(path);
} catch (e) {
if (e.message.startsWith('EACCES')) {
// it might be symlink
statValue = await pfs.Promises.lstat(path);
}
}
return statValue ? !statValue.isDirectory() : false;
}
return false;
}