aboutsummaryrefslogtreecommitdiff
path: root/chunk.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-09 16:21:20 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-09 16:21:20 +0200
commit3e866db2accc6ed5aa65befdf21474dbc7b1ec18 (patch)
tree62670e092cbc41817edc76317a0ac2482b9480af /chunk.go
parent11404879f2e7ee02118852b6b42e19f99cb2edd9 (diff)
downloaddna-backup-3e866db2accc6ed5aa65befdf21474dbc7b1ec18.tar.gz
dna-backup-3e866db2accc6ed5aa65befdf21474dbc7b1ec18.zip
first add of restore function to Repo
Diffstat (limited to 'chunk.go')
-rw-r--r--chunk.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/chunk.go b/chunk.go
index 196152e..a1cf3cd 100644
--- a/chunk.go
+++ b/chunk.go
@@ -24,6 +24,11 @@ type BufferedChunk interface {
Bytes() []byte
}
+type RepoChunk interface {
+ Chunk
+ SetRepo(r *Repo)
+}
+
type ChunkId struct {
Ver int
Idx uint64
@@ -72,6 +77,10 @@ func (c *StoredChunk) GetId() *ChunkId {
return c.Id
}
+func (c *StoredChunk) SetRepo(r *Repo) {
+ c.repo = r
+}
+
func (c *StoredChunk) Reader() io.ReadSeeker {
// log.Printf("Chunk %d: Reading from file\n", c.id)
return c.repo.LoadChunkContent(c.Id)
@@ -121,6 +130,10 @@ type DeltaChunk struct {
Size int
}
+func (c *DeltaChunk) SetRepo(r *Repo) {
+ c.repo = r
+}
+
func (c *DeltaChunk) Reader() io.ReadSeeker {
var buff bytes.Buffer
c.repo.Patcher().Patch(c.repo.LoadChunkContent(c.Source), &buff, bytes.NewReader(c.Patch))