This commit is contained in:
Eugene Pankov
2021-07-07 21:33:26 +02:00
parent 4534eefc1d
commit a159890cba
12 changed files with 40 additions and 34 deletions

View File

@@ -176,7 +176,8 @@ export class SFTPFileHandle {
while (true) {
const wait = this.sftp.write(this.handle, chunk, 0, chunk.length, this.position, err => {
if (err) {
return reject(err)
reject(err)
return
}
this.position += chunk.length
resolve()
@@ -405,7 +406,8 @@ export class SSHSession extends BaseSession {
const forward = this.forwardedPorts.find(x => x.port === details.destPort)
if (!forward) {
this.emitServiceMessage(colors.bgRed.black(' X ') + ` Rejected incoming forwarded connection for unrecognized port ${details.destPort}`)
return reject()
reject()
return
}
const socket = new Socket()
socket.connect(forward.targetPort, forward.targetAddress)
@@ -560,7 +562,8 @@ export class SSHSession extends BaseSession {
if (err) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote has rejected the forwarded connection to ${targetAddress}:${targetPort} via ${fw}: ${err}`)
return reject()
reject()
return
}
const socket = accept()
stream.pipe(socket)
@@ -587,7 +590,8 @@ export class SSHSession extends BaseSession {
if (err) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote rejected port forwarding for ${fw}: ${err}`)
return reject(err)
reject(err)
return
}
resolve()
})

View File

@@ -19,11 +19,10 @@ export class SFTPDeleteModalComponent extends BaseComponent {
super()
}
ngOnInit (): void {
async ngOnInit (): Promise<void> {
this.destroyed$.subscribe(() => this.cancel())
this.run(this.item).then(() => {
this.modalInstance.close()
})
await this.run(this.item)
this.modalInstance.close()
}
cancel (): void {

View File

@@ -33,7 +33,7 @@ export class SFTPPanelComponent {
async ngOnInit (): Promise<void> {
this.sftp = await this.session.openSFTP()
this.navigate(this.path)
await this.navigate(this.path)
}
async navigate (newPath: string): Promise<void> {
@@ -75,25 +75,23 @@ export class SFTPPanelComponent {
async open (item: SFTPFile): Promise<void> {
if (item.isDirectory) {
this.navigate(item.fullPath)
await this.navigate(item.fullPath)
} else if (item.isSymlink) {
const target = path.resolve(this.path, await this.sftp.readlink(item.fullPath))
const stat = await this.sftp.stat(target)
if (stat.isDirectory) {
this.navigate(item.fullPath)
await this.navigate(item.fullPath)
} else {
this.download(item.fullPath, stat.size)
await this.download(item.fullPath, stat.size)
}
} else {
this.download(item.fullPath, item.size)
await this.download(item.fullPath, item.size)
}
}
async upload (): Promise<void> {
const transfers = await this.platform.startUpload({ multiple: true })
for (const transfer of transfers) {
this.uploadOne(transfer)
}
await Promise.all(transfers.map(t => this.uploadOne(t)))
}
async uploadOne (transfer: FileUpload): Promise<void> {
@@ -111,7 +109,7 @@ export class SFTPPanelComponent {
handle.close()
transfer.close()
if (this.path === savedPath) {
this.navigate(this.path)
await this.navigate(this.path)
}
} catch (e) {
transfer.cancel()

View File

@@ -98,7 +98,8 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
(err, stream) => {
if (err) {
jumpSession.emitServiceMessage(colors.bgRed.black(' X ') + ` Could not set up port forward on ${jumpConnection.name}`)
return reject(err)
reject(err)
return
}
resolve(stream)
}