potentially fix Zmodem corruption issues

This commit is contained in:
Eugene Pankov 2022-03-12 19:02:03 +01:00
parent 2c00b9a4bc
commit f6c0dd6ad3
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -4,6 +4,7 @@ import { ipcMain } from 'electron'
import { Application } from './app'
import { UTF8Splitter } from './utfSplitter'
import { Subject, debounceTime } from 'rxjs'
import { StringDecoder } from './stringDecoder'
class PTYDataQueue {
private buffers: Buffer[] = []
@ -90,6 +91,7 @@ class PTYDataQueue {
export class PTY {
private pty: nodePTY.IPty
private outputQueue: PTYDataQueue
private decoder = new StringDecoder()
exited = false
constructor (private id: string, private app: Application, ...args: any[]) {
@ -99,7 +101,7 @@ export class PTY {
}
this.outputQueue = new PTYDataQueue(this.pty, data => {
setImmediate(() => this.emit('data', data))
setImmediate(() => this.emit('data', this.decoder.write(data)))
})
this.pty.onData(data => this.outputQueue.push(Buffer.from(data)))