Skip to content

Commit

Permalink
Remove "stale workspace" fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoofsKelvin committed Oct 2, 2021
1 parent 865969f commit b821bae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

## Unreleased

### Fixes
- Fix remote `code` command (#267) not working without the filesystem already connected (#292)

### Changes
- Proxy hop field now actually lists all known configs to pick from, instead of "TO DO" (#290)

Expand Down
18 changes: 0 additions & 18 deletions src/fileSystemRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ import * as vscode from 'vscode';
import { Logging } from './logging';
import type { Manager } from './manager';

function isWorkspaceStale(uri: vscode.Uri) {
for (const folder of vscode.workspace.workspaceFolders || []) {
if (folder.uri.scheme !== 'ssh') continue;
if (folder.uri.authority === uri.authority) return false;
}
return true;
}

export class FileSystemRouter implements vscode.FileSystemProvider {
public onDidChangeFile: vscode.Event<vscode.FileChangeEvent[]>;
protected onDidChangeFileEmitter = new vscode.EventEmitter<vscode.FileChangeEvent[]>();
Expand All @@ -19,16 +11,6 @@ export class FileSystemRouter implements vscode.FileSystemProvider {
public async assertFs(uri: vscode.Uri): Promise<vscode.FileSystemProvider> {
const fs = this.manager.getFs(uri);
if (fs) return fs;
// There are some edge cases where vscode tries to access files of a WorkspaceFolder
// that's (being) removed, or it's being added but the window is supposed to reload.
// We only check the first case here
if (isWorkspaceStale(uri)) {
Logging.warning(`Stale workspace for '${uri}', returning empty file system`);
// Throwing an error gives the "${root} · Can not resolve workspace folder"
// throw vscode.FileSystemError.Unavailable('Stale workspace');
// So let's just act as if everything's fine, but there's only the void.
return (await import('./sshFileSystem')).EMPTY_FILE_SYSTEM;
}
return this.manager.createFileSystem(uri.authority);
}
/* FileSystemProvider */
Expand Down
16 changes: 0 additions & 16 deletions src/sshFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,3 @@ export class SSHFileSystem implements vscode.FileSystemProvider {
if (doThrow) return doThrow(e);
}
}

export const EMPTY_FILE_SYSTEM = {
onDidChangeFile: new vscode.EventEmitter<vscode.FileChangeEvent[]>().event,
watch: (uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }) => new vscode.Disposable(() => { }),
stat: (uri: vscode.Uri) => {
console.warn('Checking', uri.toString());
if (uri.path === '/' || uri.path === '\\') return ({ type: vscode.FileType.Directory }) as vscode.FileStat;
throw vscode.FileSystemError.FileNotFound(uri);
},
readDirectory: (uri: vscode.Uri) => [],
createDirectory: (uri: vscode.Uri) => { },
readFile: (uri: vscode.Uri) => new Uint8Array(0),
writeFile: (uri: vscode.Uri, content: Uint8Array, options: { create: boolean; overwrite: boolean; }) => { },
delete: (uri: vscode.Uri, options: { recursive: boolean; }) => { },
rename: (oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean; }) => { },
} as vscode.FileSystemProvider;

0 comments on commit b821bae

Please sign in to comment.