mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-16 13:34:48 +02:00
Wire up the rsync code in the send kitten
This commit is contained in:
@@ -608,9 +608,11 @@ func (r *rsync) CreateDelta(source io.Reader, signature []BlockHash) ([]Operatio
|
||||
}
|
||||
}
|
||||
|
||||
const DataSizeMultiple int = 8
|
||||
|
||||
func (r *rsync) CreateDiff(source io.Reader, signature []BlockHash, output io.Writer) func() error {
|
||||
ans := &diff{
|
||||
block_size: r.BlockSize, buffer: make([]byte, 0, (r.BlockSize * 8)),
|
||||
block_size: r.BlockSize, buffer: make([]byte, 0, (r.BlockSize * DataSizeMultiple)),
|
||||
hash_lookup: make(map[uint32][]BlockHash, len(signature)),
|
||||
source: source, hasher: r.hasher_constructor(),
|
||||
checksummer: r.checksummer_constructor(), output: output,
|
||||
|
||||
@@ -119,7 +119,7 @@ func (self *Api) read_signature_blocks(data []byte) (consumed int) {
|
||||
return
|
||||
}
|
||||
|
||||
func (self *Differ) finish_signature_data() (err error) {
|
||||
func (self *Differ) FinishSignatureData() (err error) {
|
||||
if len(self.unconsumed_signature_data) > 0 {
|
||||
return fmt.Errorf("There were %d leftover bytes in the signature data", len(self.unconsumed_signature_data))
|
||||
}
|
||||
@@ -225,7 +225,7 @@ func (self *Patcher) CreateSignatureIterator(src io.Reader, output io.Writer) fu
|
||||
|
||||
// Create a serialized delta based on the previously loaded signature
|
||||
func (self *Differ) CreateDelta(src io.Reader, output io.Writer) func() error {
|
||||
if err := self.finish_signature_data(); err != nil {
|
||||
if err := self.FinishSignatureData(); err != nil {
|
||||
return func() error { return err }
|
||||
}
|
||||
if self.signature == nil {
|
||||
@@ -236,6 +236,10 @@ func (self *Differ) CreateDelta(src io.Reader, output io.Writer) func() error {
|
||||
return self.rsync.CreateDiff(src, self.signature, output)
|
||||
}
|
||||
|
||||
func (self *Differ) BlockSize() int {
|
||||
return self.rsync.BlockSize
|
||||
}
|
||||
|
||||
// Add more external signature data
|
||||
func (self *Differ) AddSignatureData(data []byte) (err error) {
|
||||
self.unconsumed_signature_data = append(self.unconsumed_signature_data, data...)
|
||||
|
||||
Reference in New Issue
Block a user