mirror of
https://github.com/Microsoft/vscode
synced 2024-10-13 06:48:17 +00:00
vscode.workspace.fs.readDirectory() ignores broken symlinks. (fix #90031)
This commit is contained in:
parent
7ed9930136
commit
c739b34b50
|
@ -98,7 +98,18 @@ export class DiskFileSystemProvider extends Disposable implements
|
|||
try {
|
||||
let type: FileType;
|
||||
if (child.isSymbolicLink()) {
|
||||
type = (await this.stat(joinPath(resource, child.name))).type; // always resolve target the link points to if any
|
||||
try {
|
||||
type = (await this.stat(joinPath(resource, child.name))).type; // always resolve target the link points to if any
|
||||
} catch (error) {
|
||||
if (error.code !== FileSystemProviderErrorCode.FileNotFound) {
|
||||
throw error; // any error that is not file not found is unexpected
|
||||
}
|
||||
|
||||
// a symbolic link can point to a target that does
|
||||
// not exist on the file system. in that case we
|
||||
// still want to return the element as UNKNOWN.
|
||||
type = FileType.SymbolicLink | FileType.Unknown;
|
||||
}
|
||||
} else {
|
||||
type = this.toType(child);
|
||||
}
|
||||
|
|
|
@ -440,7 +440,7 @@ suite('Disk File Service', function () {
|
|||
assert.equal(resolved.isSymbolicLink, true);
|
||||
});
|
||||
|
||||
test('resolve - invalid symbolic link does not break', async () => {
|
||||
test('resolve - symbolic link pointing to non-existing file does not break', async () => {
|
||||
if (isWindows) {
|
||||
return; // not reliable on windows
|
||||
}
|
||||
|
@ -450,7 +450,13 @@ suite('Disk File Service', function () {
|
|||
|
||||
const resolved = await service.resolve(URI.file(testDir));
|
||||
assert.equal(resolved.isDirectory, true);
|
||||
assert.equal(resolved.children!.length, 8);
|
||||
assert.equal(resolved.children!.length, 9);
|
||||
|
||||
const resolvedLink = resolved.children?.filter(child => child.name === 'bar' && child.isSymbolicLink)[0];
|
||||
assert.ok(resolvedLink);
|
||||
|
||||
assert.ok(!resolvedLink?.isDirectory);
|
||||
assert.ok(!resolvedLink?.isFile);
|
||||
});
|
||||
|
||||
test('deleteFile', async () => {
|
||||
|
|
Loading…
Reference in a new issue