1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-21 17:41:38 +03:00

fixed multiple sftp uploads - fixes #4001

This commit is contained in:
Eugene Pankov 2021-06-18 21:58:25 +02:00
parent 5ef0ae6d44
commit 907ebc0fd5
2 changed files with 6 additions and 7 deletions

View File

@ -29,7 +29,7 @@ export class DropZoneDirective implements AfterViewInit {
}) })
this.el.nativeElement.addEventListener('drop', (event: DragEvent) => { this.el.nativeElement.addEventListener('drop', (event: DragEvent) => {
this.removeHint() this.removeHint()
for (const transfer of this.platform.startUploadFromDragEvent(event)) { for (const transfer of this.platform.startUploadFromDragEvent(event, true)) {
this.transfer.emit(transfer) this.transfer.emit(transfer)
} }
}) })

View File

@ -91,18 +91,14 @@ export class SFTPPanelComponent {
async upload (): Promise<void> { async upload (): Promise<void> {
const transfers = await this.platform.startUpload({ multiple: true }) const transfers = await this.platform.startUpload({ multiple: true })
const savedPath = this.path
for (const transfer of transfers) { for (const transfer of transfers) {
this.uploadOne(transfer).then(() => { this.uploadOne(transfer)
if (this.path === savedPath) {
this.navigate(this.path)
}
})
} }
} }
async uploadOne (transfer: FileUpload): Promise<void> { async uploadOne (transfer: FileUpload): Promise<void> {
const itemPath = path.join(this.path, transfer.getName()) const itemPath = path.join(this.path, transfer.getName())
const savedPath = this.path
try { try {
const handle = await this.sftp.open(itemPath, 'w') const handle = await this.sftp.open(itemPath, 'w')
while (true) { while (true) {
@ -114,6 +110,9 @@ export class SFTPPanelComponent {
} }
handle.close() handle.close()
transfer.close() transfer.close()
if (this.path === savedPath) {
this.navigate(this.path)
}
} catch (e) { } catch (e) {
transfer.cancel() transfer.cancel()
throw e throw e