1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-27 10:42:35 +03:00

zmodem fixes (fixes #1949)

This commit is contained in:
Eugene Pankov 2020-01-14 11:41:05 +01:00
parent 472b421484
commit 5507171fee

View File

@ -15,7 +15,6 @@ const SPACER = ' '
export class ZModemDecorator extends TerminalDecorator {
private subscriptions: Subscription[] = []
private logger: Logger
private sentry
private activeSession: any = null
constructor (
@ -28,8 +27,12 @@ export class ZModemDecorator extends TerminalDecorator {
}
attach (terminal: TerminalTabComponent): void {
this.sentry = new ZModem.Sentry({
to_terminal: () => null,
const sentry = new ZModem.Sentry({
to_terminal: data => {
if (!terminal.enablePassthrough) {
terminal.write(data)
}
},
sender: data => terminal.session.write(Buffer.from(data)),
on_detect: async detection => {
try {
@ -49,7 +52,7 @@ export class ZModemDecorator extends TerminalDecorator {
const chunkSize = 1024
for (let i = 0; i <= Math.floor(data.length / chunkSize); i++) {
try {
this.sentry.consume(data.subarray(i * chunkSize, (i + 1) * chunkSize))
sentry.consume(data.subarray(i * chunkSize, (i + 1) * chunkSize))
} catch (e) {
this.logger.error('protocol error', e)
this.activeSession.abort()