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. --- repo.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'repo.go') diff --git a/repo.go b/repo.go index 50eeb25..f7aa5e9 100644 --- a/repo.go +++ b/repo.go @@ -299,18 +299,8 @@ func (r *Repo) loadChunks(versions []string, chunks chan<- IdentifiedChunk) { if e.IsDir() { continue } - f := filepath.Join(p, e.Name()) - buff, err := os.ReadFile(f) - if err != nil { - log.Printf("Error reading chunk '%s': %s", f, err.Error()) - } - c := NewLoadedChunk( - &ChunkId{ - Ver: i, - Idx: uint64(j), - }, - buff, - ) + id := &ChunkId{Ver: i, Idx: uint64(j)} + c := NewStoredChunk(r, id) chunks <- c } } -- cgit v1.2.3