Skip to content

Commit f262c79

Browse files
authored
Fix mkdir failing on remote from guest (#181)
1 parent 5333c40 commit f262c79

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/open-collaboration-vscode/src/collaboration-file-system.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,20 @@ export class CollaborationFileSystemProvider implements vscode.FileSystemProvide
6565
}
6666
async stat(uri: vscode.Uri): Promise<vscode.FileStat> {
6767
const path = this.getHostPath(uri);
68-
const stat = await this.connection.fs.stat(this.hostId, path);
69-
return stat;
68+
try {
69+
const stat = await this.connection.fs.stat(this.hostId, path);
70+
return stat;
71+
} catch (err) {
72+
if (err instanceof vscode.FileSystemError) {
73+
throw err;
74+
}
75+
// throw again as FileNotFound so vscode treats it as "path doesn't exist" rather than a fatal error
76+
// allows mkdir to happen after the stat fails
77+
if (err instanceof Error && (err.message.includes('ENOENT') || err.message.includes('not found'))) {
78+
throw vscode.FileSystemError.FileNotFound(uri);
79+
}
80+
throw vscode.FileSystemError.Unavailable(`Failed to stat ${uri.toString()}: ${err}`);
81+
}
7082
}
7183
async readDirectory(uri: vscode.Uri): Promise<Array<[string, vscode.FileType]>> {
7284
const path = this.getHostPath(uri);

0 commit comments

Comments
 (0)