This commit is contained in:
Kovid Goyal
2023-07-04 04:56:30 +05:30
parent f27bb2103f
commit 26c93af565
3 changed files with 6 additions and 2 deletions

View File

@@ -82,6 +82,7 @@ func (self *Operation) Unserialize(data []byte) (n int, err error) {
return -1, io.ErrShortBuffer
}
self.BlockIndex = bin.Uint64(data[1:])
self.Data = nil
case OpBlockRange:
n = 13
if len(data) < n {
@@ -89,6 +90,7 @@ func (self *Operation) Unserialize(data []byte) (n int, err error) {
}
self.BlockIndex = bin.Uint64(data[1:])
self.BlockIndexEnd = self.BlockIndex + uint64(bin.Uint32(data[9:]))
self.Data = nil
case OpHash:
n = 3
if len(data) < n {

View File

@@ -116,7 +116,9 @@ func (self *Patcher) update_delta(data []byte) (consumed int, err error) {
if err = self.rsync.ApplyDelta(self.delta_output, self.delta_input, op); err != nil {
return
}
self.total_data_in_delta += len(op.Data)
if op.Type == OpData {
self.total_data_in_delta += len(op.Data)
}
} else {
if n < 0 {
return consumed, nil

View File

@@ -24,7 +24,7 @@ func TestRsyncRoundtrip(t *testing.T) {
random_patch := func(data []byte) (size int) {
if offset := random.Int(len(data)); offset < len(data) {
max_size := utils.Min(256, len(data)-offset)
max_size := utils.Min(257, len(data)-offset)
if size = random.Int(max_size); size > 0 {
total_patch_size += size
random.Bytes(data[offset : offset+size])