Clean imports and some other code

pull/64/head
Kelvin Schoofs 6 years ago
parent 8c2360b0ef
commit 30d8a7b080

@ -1,12 +1,8 @@
import * as fs from 'fs';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { invalidConfigName, loadConfigs } from './config'; import { invalidConfigName, loadConfigs } from './config';
import { MemFs } from './fileSystemProvider';
import { Manager } from './manager'; import { Manager } from './manager';
const workspace = vscode.workspace;
async function pickConfig(manager: Manager, activeOrNot?: boolean) { async function pickConfig(manager: Manager, activeOrNot?: boolean) {
let names = manager.getActive(); let names = manager.getActive();
const others = loadConfigs(); const others = loadConfigs();

@ -3,10 +3,9 @@ import { readFile } from 'fs';
import { parse as parseJsonc, ParseError } from 'jsonc-parser'; import { parse as parseJsonc, ParseError } from 'jsonc-parser';
import * as path from 'path'; import * as path from 'path';
import { Client, ClientChannel, ConnectConfig } from 'ssh2'; import { Client, ClientChannel, ConnectConfig } from 'ssh2';
import { SFTPStream } from 'ssh2-streams';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { getConfig, loadConfigs, openConfigurationEditor, updateConfig } from './config'; import { getConfig, loadConfigs, openConfigurationEditor, updateConfig } from './config';
import { createSocket, createSSH, getSFTP } from './connect'; import { createSSH, getSFTP } from './connect';
import SSHFileSystem, { EMPTY_FILE_SYSTEM } from './sshFileSystem'; import SSHFileSystem, { EMPTY_FILE_SYSTEM } from './sshFileSystem';
import { MemoryDuplex } from './streams'; import { MemoryDuplex } from './streams';
import { catchingPromise, toPromise } from './toPromise'; import { catchingPromise, toPromise } from './toPromise';
@ -15,7 +14,6 @@ async function assertFs(man: Manager, uri: vscode.Uri) {
const fs = await man.getFs(uri); const fs = await man.getFs(uri);
if (fs) return fs; if (fs) return fs;
return man.createFileSystem(uri.authority); return man.createFileSystem(uri.authority);
// throw new Error(`A SSH filesystem with the name '${uri.authority}' doesn't exists`);
} }
export interface ProxyConfig { export interface ProxyConfig {
@ -126,7 +124,6 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
protected configFileSystem = createConfigFs(this); protected configFileSystem = createConfigFs(this);
protected onDidChangeFileEmitter = new vscode.EventEmitter<vscode.FileChangeEvent[]>(); protected onDidChangeFileEmitter = new vscode.EventEmitter<vscode.FileChangeEvent[]>();
protected onDidChangeTreeDataEmitter = new vscode.EventEmitter<string>(); protected onDidChangeTreeDataEmitter = new vscode.EventEmitter<string>();
// private memento: vscode.Memento = this.context.globalState;
constructor(public readonly context: vscode.ExtensionContext) { constructor(public readonly context: vscode.ExtensionContext) {
this.onDidChangeFile = this.onDidChangeFileEmitter.event; this.onDidChangeFile = this.onDidChangeFileEmitter.event;
this.onDidChangeTreeData = this.onDidChangeTreeDataEmitter.event; this.onDidChangeTreeData = this.onDidChangeTreeDataEmitter.event;
@ -178,7 +175,6 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
if (existing) return existing; if (existing) return existing;
let promise = this.creatingFileSystems[name]; let promise = this.creatingFileSystems[name];
if (promise) return promise; if (promise) return promise;
// config = config || this.memento.get(`fs.config.${name}`);
config = config || loadConfigs().find(c => c.name === name); config = config || loadConfigs().find(c => c.name === name);
promise = catchingPromise<SSHFileSystem>(async (resolve, reject) => { promise = catchingPromise<SSHFileSystem>(async (resolve, reject) => {
if (!config) { if (!config) {
@ -261,6 +257,7 @@ export class Manager implements vscode.FileSystemProvider, vscode.TreeDataProvid
} }
/* FileSystemProvider */ /* FileSystemProvider */
public watch(uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }): vscode.Disposable { public watch(uri: vscode.Uri, options: { recursive: boolean; excludes: string[]; }): vscode.Disposable {
// TODO: Store watched files/directories in an array and periodically check if they're modified
/*let disp = () => {}; /*let disp = () => {};
assertFs(this, uri).then((fs) => { assertFs(this, uri).then((fs) => {
disp = fs.watch(uri, options).dispose.bind(fs); disp = fs.watch(uri, options).dispose.bind(fs);

@ -1,6 +1,5 @@
import * as Winreg from 'winreg'; import * as Winreg from 'winreg';
import { toPromise } from './toPromise'; import { toPromise } from './toPromise';
const winreg = new Winreg({ const winreg = new Winreg({

@ -1,5 +1,5 @@
import { Duplex, Stream, Writable } from 'stream'; import { Duplex, Writable } from 'stream';
export class MemoryDuplex extends Duplex { export class MemoryDuplex extends Duplex {
protected buffer = new Buffer(this.size); protected buffer = new Buffer(this.size);

Loading…
Cancel
Save