diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-09-09 16:21:20 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-09-09 16:21:20 +0200 |
commit | 3e866db2accc6ed5aa65befdf21474dbc7b1ec18 (patch) | |
tree | 62670e092cbc41817edc76317a0ac2482b9480af /chunk.go | |
parent | 11404879f2e7ee02118852b6b42e19f99cb2edd9 (diff) | |
download | dna-backup-3e866db2accc6ed5aa65befdf21474dbc7b1ec18.tar.gz dna-backup-3e866db2accc6ed5aa65befdf21474dbc7b1ec18.zip |
first add of restore function to Repo
Diffstat (limited to 'chunk.go')
-rw-r--r-- | chunk.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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)) |