Skip to content

Commit

Permalink
Fix a couple of infinite loops
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jul 2, 2023
1 parent 32880c2 commit cf19412
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions kittens/transfer/ftc.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,8 @@ func split_for_transfer(data []byte, file_id string, mark_last bool, callback fu
chunk := data
if len(chunk) > chunk_size {
chunk = data[:chunk_size]
data = data[chunk_size:]
}
callback(&FileTransmissionCommand{Action: ac, File_id: file_id, Data: chunk})

data = data[len(chunk):]
}
}
4 changes: 2 additions & 2 deletions kittens/transfer/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ 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())
self.activate_next_ready_file()
}
}
}
Expand Down Expand Up @@ -1007,8 +1008,7 @@ func (self *SendHandler) start_transfer() (err error) {
if self.manager.active_file() != nil {
self.transmit_started = true
self.manager.progress_tracker.start_transfer()
err = self.transmit_next_chunk()
if err != nil {
if err = self.transmit_next_chunk(); err != nil {
return
}
self.draw_progress()
Expand Down

0 comments on commit cf19412

Please sign in to comment.