Remove "stale workspace" fix

feature/forwarding
Kelvin Schoofs 3 years ago
parent 14e26a791b
commit 13357c8133

@ -2,14 +2,6 @@ import * as vscode from 'vscode';
import { Logging } from './logging'; import { Logging } from './logging';
import type { Manager } from './manager'; 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 { export class FileSystemRouter implements vscode.FileSystemProvider {
public onDidChangeFile: vscode.Event<vscode.FileChangeEvent[]>; public onDidChangeFile: vscode.Event<vscode.FileChangeEvent[]>;
protected onDidChangeFileEmitter = new vscode.EventEmitter<vscode.FileChangeEvent[]>(); protected onDidChangeFileEmitter = new vscode.EventEmitter<vscode.FileChangeEvent[]>();
@ -19,16 +11,6 @@ export class FileSystemRouter implements vscode.FileSystemProvider {
public async assertFs(uri: vscode.Uri): Promise<vscode.FileSystemProvider> { public async assertFs(uri: vscode.Uri): Promise<vscode.FileSystemProvider> {
const fs = this.manager.getFs(uri); const fs = this.manager.getFs(uri);
if (fs) return fs; 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); return this.manager.createFileSystem(uri.authority);
} }
/* FileSystemProvider */ /* FileSystemProvider */

@ -202,19 +202,3 @@ export class SSHFileSystem implements vscode.FileSystemProvider {
if (doThrow) return doThrow(e); 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;

Loading…
Cancel
Save