From 3e0123b9d8a1097e74fcd500b72cbdaa00c7a49a Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 13 Sep 2021 15:23:32 +0200 Subject: fix loadChunks by using cache instead of reading file This way there is only one place where we read chunks and where the read/write wrapper is used. This also allows to remove LoadedChunk as it is not used anymore. --- chunk.go | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'chunk.go') diff --git a/chunk.go b/chunk.go index 0d84040..3efaf4a 100644 --- a/chunk.go +++ b/chunk.go @@ -36,32 +36,6 @@ func (i *ChunkId) Path(repo string) string { return filepath.Join(repo, fmt.Sprintf(versionFmt, i.Ver), chunksName, fmt.Sprintf(chunkIdFmt, i.Idx)) } -func NewLoadedChunk(id *ChunkId, value []byte) *LoadedChunk { - return &LoadedChunk{Id: id, value: value} -} - -type LoadedChunk struct { - Id *ChunkId - value []byte -} - -func (c *LoadedChunk) GetId() *ChunkId { - return c.Id -} - -func (c *LoadedChunk) Reader() io.ReadSeeker { - // log.Printf("Chunk %d: Reading from in-memory value\n", c.id) - return bytes.NewReader(c.value) -} - -func (c *LoadedChunk) Len() int { - return len(c.value) -} - -func (c *LoadedChunk) Bytes() []byte { - return c.value -} - func NewStoredChunk(repo *Repo, id *ChunkId) *StoredChunk { return &StoredChunk{repo: repo, Id: id} } -- cgit v1.2.3