Skip to content

Commit

Permalink
fix: do not immediately ignore thrown error
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Apr 15, 2024
1 parent 36c9c23 commit 14e4e3a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/service-override/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,15 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC

async writeFile (resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise<void> {
await this.writeToDelegates(async delegate => {
let stats: IStat | undefined
try {
const stats = await delegate.stat(resource)
if (((stats.permissions ?? 0) & FilePermission.Readonly) > 0) {
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions)
}
stats = await delegate.stat(resource)
} catch (err) {
// ignore
}
if (stats != null && ((stats.permissions ?? 0) & FilePermission.Readonly) > 0) {
throw createFileSystemProviderError('Not allowed', FileSystemProviderErrorCode.NoPermissions)
}
return delegate.writeFile(resource, content, opts)
})
}
Expand Down

0 comments on commit 14e4e3a

Please sign in to comment.