mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-27 03:42:49 +00:00
Fix a bug in upstream CreateDelta that could ignore trailing data if a matching hash is not found for it
This commit is contained in:
parent
82721ef053
commit
79fd0b19cf
2 changed files with 34 additions and 20 deletions
|
|
@ -54,17 +54,22 @@ func TestRsyncRoundtrip(t *testing.T) {
|
|||
signature = append(signature, s)
|
||||
return nil
|
||||
})
|
||||
delta_ops := make([]Operation, 0, 128)
|
||||
p.rsync.CreateDelta(bytes.NewReader(src_data), signature, func(op Operation) error {
|
||||
op.Data = slices.Clone(op.Data)
|
||||
delta_ops = append(delta_ops, op)
|
||||
return nil
|
||||
})
|
||||
outputbuf := bytes.Buffer{}
|
||||
for _, op := range delta_ops {
|
||||
p.rsync.ApplyDelta(&outputbuf, bytes.NewReader(src_data), op)
|
||||
|
||||
apply_delta := func(signature []BlockHash) []byte {
|
||||
delta_ops := make([]Operation, 0, 1024)
|
||||
p.rsync.CreateDelta(bytes.NewReader(src_data), signature, func(op Operation) error {
|
||||
op.Data = slices.Clone(op.Data)
|
||||
delta_ops = append(delta_ops, op)
|
||||
return nil
|
||||
})
|
||||
outputbuf := bytes.Buffer{}
|
||||
for _, op := range delta_ops {
|
||||
p.rsync.ApplyDelta(&outputbuf, bytes.NewReader(src_data), op)
|
||||
}
|
||||
return outputbuf.Bytes()
|
||||
}
|
||||
test_equal(src_data, outputbuf.Bytes())
|
||||
test_equal(src_data, apply_delta(nil))
|
||||
test_equal(src_data, apply_delta(signature))
|
||||
|
||||
// Now try with serialization
|
||||
p = NewPatcher(int64(len(src_data)))
|
||||
|
|
@ -80,7 +85,7 @@ func TestRsyncRoundtrip(t *testing.T) {
|
|||
if err := d.CreateDelta(bytes.NewReader(src_data), func(b []byte) error { _, err := deltabuf.Write(b); return err }); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outputbuf = bytes.Buffer{}
|
||||
outputbuf := bytes.Buffer{}
|
||||
p.StartDelta(&outputbuf, bytes.NewReader(src_data))
|
||||
b := make([]byte, 30*1024)
|
||||
for {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue