From 1dec2cdc84a6497c893d84485c6f94589f997215 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Wed, 1 Sep 2021 19:07:49 +0200 Subject: Prepare for delta encoding --- chunk.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'chunk.go') diff --git a/chunk.go b/chunk.go index 9927c94..3fc9057 100644 --- a/chunk.go +++ b/chunk.go @@ -115,3 +115,20 @@ func (c *TempChunk) AppendFrom(r io.Reader) { } c.value = append(c.value, buff...) } + +type DeltaChunk struct { + repo *Repo + source *ChunkId + patch []byte + size int +} + +func (c *DeltaChunk) Reader() ChunkReader { + var buff bytes.Buffer + c.repo.Patcher().Patch(c.source.Reader(c.repo), &buff, bytes.NewReader(c.patch)) + return &buff +} + +func (c *DeltaChunk) Len() int { + return c.size +} -- cgit v1.2.3