More work on porting the receive kitten

This commit is contained in:
Kovid Goyal
2023-07-24 08:14:58 +05:30
parent 14c29f2cf5
commit 6b5520f07a
5 changed files with 74 additions and 4 deletions

View File

@@ -195,6 +195,7 @@ type rsync struct {
hasher_constructor func() hash.Hash64
checksummer_constructor func() hash.Hash
checksummer hash.Hash
checksum_done bool
buffer []byte
}
@@ -319,6 +320,7 @@ func (r *rsync) ApplyDelta(alignedTarget io.Writer, target io.ReadSeeker, op Ope
if !bytes.Equal(actual, op.Data) {
return fmt.Errorf("Failed to verify overall file checksum actual: %s != expected: %s. This usually happens if some data was corrupted in transit or one of the involved files was altered while the transfer was in progress.", hex.EncodeToString(actual), hex.EncodeToString(op.Data))
}
r.checksum_done = true
}
return nil
}

View File

@@ -185,6 +185,9 @@ func (self *Patcher) FinishDelta() (err error) {
self.delta_input = nil
self.delta_output = nil
self.unconsumed_delta_data = nil
if !self.rsync.checksum_done {
return fmt.Errorf("The checksum was not received at the end of the delta data")
}
return
}