File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
packages/open-collaboration-vscode/src Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments