mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
More misc send fixes
This commit is contained in:
@@ -330,15 +330,15 @@ func NewFileTransmissionCommand(serialized string) (ans *FileTransmissionCommand
|
||||
func split_for_transfer(data []byte, file_id string, mark_last bool, callback func(*FileTransmissionCommand)) {
|
||||
const chunk_size = 4096
|
||||
for len(data) > 0 {
|
||||
ac := Action_data
|
||||
if mark_last && len(data) <= chunk_size {
|
||||
ac = Action_end_data
|
||||
}
|
||||
chunk := data
|
||||
if len(chunk) > chunk_size {
|
||||
chunk = data[:chunk_size]
|
||||
}
|
||||
callback(&FileTransmissionCommand{Action: ac, File_id: file_id, Data: chunk})
|
||||
data = data[len(chunk):]
|
||||
ac := Action_data
|
||||
if mark_last && len(data) == 0 {
|
||||
ac = Action_end_data
|
||||
}
|
||||
callback(&FileTransmissionCommand{Action: ac, File_id: file_id, Data: chunk})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ func (self *ZlibCompressor) Compress(data []byte) []byte {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer self.b.Reset()
|
||||
return utils.UnsafeStringToBytes(self.b.String())
|
||||
}
|
||||
|
||||
@@ -979,7 +980,12 @@ func (self *SendManager) next_chunks(callback func(string)) error {
|
||||
split_for_transfer(utils.UnsafeStringToBytes(chunk), af.file_id, is_last, func(ftc *FileTransmissionCommand) { callback(ftc.Serialize()) })
|
||||
} else if is_last {
|
||||
callback(FileTransmissionCommand{Action: Action_end_data, File_id: af.file_id}.Serialize())
|
||||
}
|
||||
if is_last {
|
||||
self.activate_next_ready_file()
|
||||
if self.active_file() == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user