Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few minor fixes #400

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"@vscode/proxy-agent": "^0.19.0",
"@vscode/ripgrep": "^1.15.9",
"@vscode/spdlog": "^0.15.0",
"@vscode/vscode-languagedetection": "1.0.21",
"@vscode/vscode-languagedetection": "npm:@codingame/vscode-languagedetection@1.0.23",
"@vscode/windows-process-tree": "^0.6.0",
"@vscode/windows-registry": "^1.1.0",
"@xterm/addon-canvas": "0.7.0-beta.12",
Expand Down
19 changes: 10 additions & 9 deletions src/service-override/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC
throw firstError
}

private async writeToDelegates (resource: URI, caller: (delegate: IFileSystemProviderWithFileReadWriteCapability) => Promise<void>): Promise<void> {
private async writeToDelegates (caller: (delegate: IFileSystemProviderWithFileReadWriteCapability) => Promise<void>): Promise<void> {
for (const provider of this.delegates) {
if ((provider.capabilities & FileSystemProviderCapabilities.Readonly) > 0) {
continue
Expand Down Expand Up @@ -378,29 +378,30 @@ class OverlayFileSystemProvider implements IFileSystemProviderWithFileReadWriteC
}

async writeFile (resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise<void> {
await this.writeToDelegates(resource, async delegate => {
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)
})
}

async mkdir (resource: URI): Promise<void> {
await this.writeToDelegates(resource, delegate => delegate.mkdir(resource))
await this.writeToDelegates(delegate => delegate.mkdir(resource))
}

async delete (resource: URI, opts: IFileDeleteOptions): Promise<void> {
await this.writeToDelegates(resource, delegate => delegate.delete(resource, opts))
await this.writeToDelegates(delegate => delegate.delete(resource, opts))
}

async rename (from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> {
await this.writeToDelegates(from, delegate => delegate.rename(from, to, opts))
await this.writeToDelegates(delegate => delegate.rename(from, to, opts))
}
}

Expand Down