From aa0439df1fd6e0f72ebe262a0d2cf37022d8ada6 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 14 Sep 2017 16:27:48 +0200 Subject: [PATCH] have unlink and rmdir --- src/vs/platform/files/common/files.ts | 7 ++++--- .../electron-browser/ftpFileSystemProvider.ts | 17 ++++++----------- .../files/electron-browser/remoteFileService.ts | 3 ++- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/vs/platform/files/common/files.ts b/src/vs/platform/files/common/files.ts index 92a263e67d6..f4f448a3abd 100644 --- a/src/vs/platform/files/common/files.ts +++ b/src/vs/platform/files/common/files.ts @@ -167,12 +167,13 @@ export interface IStat { export interface IFileSystemProvider { onDidChange?: Event; stat(resource: URI): TPromise; - readdir(resource: URI): TPromise; - mkdir(resource: URI): TPromise; read(resource: URI, progress: IProgress): TPromise; write(resource: URI, content: Uint8Array): TPromise; + unlink(resource: URI): TPromise; rename(resource: URI, target: URI): TPromise; - del(resource: URI): TPromise; + mkdir(resource: URI): TPromise; + readdir(resource: URI): TPromise; + rmdir(resource: URI): TPromise; } diff --git a/src/vs/workbench/services/files/electron-browser/ftpFileSystemProvider.ts b/src/vs/workbench/services/files/electron-browser/ftpFileSystemProvider.ts index 2867b30db59..c22fe332520 100644 --- a/src/vs/workbench/services/files/electron-browser/ftpFileSystemProvider.ts +++ b/src/vs/workbench/services/files/electron-browser/ftpFileSystemProvider.ts @@ -93,23 +93,18 @@ export class FtpFileSystemProvider implements IFileSystemProvider { return ninvoke(this._connection, this._connection.put, content, resource.path); } - del(resource: URI): TPromise { - - return ninvoke(this._connection, this._connection.ls, resource.path).then(entries => { - if (entries.length === 1) { - // file; - return ninvoke(this._connection, this._connection.raw, 'DELE', [resource.path]); - } else { - // dir - return ninvoke(this._connection, this._connection.raw, 'RMD', [resource.path]); - } - }); + rmdir(resource: URI): TPromise { + return ninvoke(this._connection, this._connection.raw, 'RMD', [resource.path]); } mkdir(resource: URI): TPromise { return ninvoke(this._connection, this._connection.raw, 'MKD', [resource.path]); } + unlink(resource: URI): TPromise { + return ninvoke(this._connection, this._connection.raw, 'DELE', [resource.path]); + } + rename(resource: URI, target: URI): TPromise { return ninvoke(this._connection, this._connection.raw, 'RNFR', [resource.path]).then(() => { return ninvoke(this._connection, this._connection.raw, 'RNTO', [target.path]); diff --git a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts index d2c1760963d..00969284031 100644 --- a/src/vs/workbench/services/files/electron-browser/remoteFileService.ts +++ b/src/vs/workbench/services/files/electron-browser/remoteFileService.ts @@ -258,7 +258,8 @@ export class RemoteFileService extends FileService { async del(resource: URI, useTrash?: boolean): TPromise { const provider = this._provider.get(resource.scheme); if (provider) { - await provider.del(resource); + const stat = await provider.stat(resource); + await stat.type === FileType.Dir ? provider.rmdir(resource) : provider.unlink(resource); this._onAfterOperation.fire(new FileOperationEvent(resource, FileOperation.DELETE)); } else { return super.del(resource, useTrash); -- GitLab