From 3e866db2accc6ed5aa65befdf21474dbc7b1ec18 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 9 Sep 2021 16:21:20 +0200 Subject: first add of restore function to Repo --- chunk.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'chunk.go') 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)) -- cgit v1.2.3