From 907ebc0fd5018b350c754b81a518bf1be551132e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Fri, 18 Jun 2021 21:58:25 +0200 Subject: [PATCH] fixed multiple sftp uploads - fixes #4001 --- terminus-core/src/directives/dropZone.directive.ts | 2 +- terminus-ssh/src/components/sftpPanel.component.ts | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/terminus-core/src/directives/dropZone.directive.ts b/terminus-core/src/directives/dropZone.directive.ts index efffb110..1da823eb 100644 --- a/terminus-core/src/directives/dropZone.directive.ts +++ b/terminus-core/src/directives/dropZone.directive.ts @@ -29,7 +29,7 @@ export class DropZoneDirective implements AfterViewInit { }) this.el.nativeElement.addEventListener('drop', (event: DragEvent) => { this.removeHint() - for (const transfer of this.platform.startUploadFromDragEvent(event)) { + for (const transfer of this.platform.startUploadFromDragEvent(event, true)) { this.transfer.emit(transfer) } }) diff --git a/terminus-ssh/src/components/sftpPanel.component.ts b/terminus-ssh/src/components/sftpPanel.component.ts index 6c5ede86..8e0893cf 100644 --- a/terminus-ssh/src/components/sftpPanel.component.ts +++ b/terminus-ssh/src/components/sftpPanel.component.ts @@ -91,18 +91,14 @@ export class SFTPPanelComponent { async upload (): Promise { const transfers = await this.platform.startUpload({ multiple: true }) - const savedPath = this.path for (const transfer of transfers) { - this.uploadOne(transfer).then(() => { - if (this.path === savedPath) { - this.navigate(this.path) - } - }) + this.uploadOne(transfer) } } async uploadOne (transfer: FileUpload): Promise { const itemPath = path.join(this.path, transfer.getName()) + const savedPath = this.path try { const handle = await this.sftp.open(itemPath, 'w') while (true) { @@ -114,6 +110,9 @@ export class SFTPPanelComponent { } handle.close() transfer.close() + if (this.path === savedPath) { + this.navigate(this.path) + } } catch (e) { transfer.cancel() throw e