File tree Expand file tree Collapse file tree
src/vs/platform/files/node Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,12 +126,18 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
126126 try {
127127 const filePath = this . toFilePath ( resource ) ;
128128
129- // Validate target
130- const fileExists = await exists ( filePath ) ;
131- if ( fileExists && ! opts . overwrite ) {
132- throw createFileSystemProviderError ( new Error ( localize ( 'fileExists' , "File already exists" ) ) , FileSystemProviderErrorCode . FileExists ) ;
133- } else if ( ! fileExists && ! opts . create ) {
134- throw createFileSystemProviderError ( new Error ( localize ( 'fileNotExists' , "File does not exist" ) ) , FileSystemProviderErrorCode . FileNotFound ) ;
129+ // Validate target unless { create: true, overwrite: true }
130+ if ( ! opts . create || ! opts . overwrite ) {
131+ const fileExists = await exists ( filePath ) ;
132+ if ( fileExists ) {
133+ if ( ! opts . overwrite ) {
134+ throw createFileSystemProviderError ( new Error ( localize ( 'fileExists' , "File already exists" ) ) , FileSystemProviderErrorCode . FileExists ) ;
135+ }
136+ } else {
137+ if ( ! opts . create ) {
138+ throw createFileSystemProviderError ( new Error ( localize ( 'fileNotExists' , "File does not exist" ) ) , FileSystemProviderErrorCode . FileNotFound ) ;
139+ }
140+ }
135141 }
136142
137143 // Open
You can’t perform that action at this time.
0 commit comments