diff options
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)) |