aboutsummaryrefslogtreecommitdiff
path: root/chunk.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-01 19:07:49 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-01 19:07:49 +0200
commit1dec2cdc84a6497c893d84485c6f94589f997215 (patch)
tree690a3a1601c54ea77878a9fae8429beac46c5919 /chunk.go
parentdb40818ef79ccb3f5f9232623f57ad284a4af7d0 (diff)
downloaddna-backup-1dec2cdc84a6497c893d84485c6f94589f997215.tar.gz
dna-backup-1dec2cdc84a6497c893d84485c6f94589f997215.zip
Prepare for delta encoding
Diffstat (limited to 'chunk.go')
-rw-r--r--chunk.go17
1 files changed, 17 insertions, 0 deletions
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
+}