From 7936be4619e10baae3cb2265169344245b1a7d13 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 13 Sep 2021 13:13:12 +0200 Subject: close opened files in loadChunkContent and Restore to try to fix tests on windows --- repo.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'repo.go') diff --git a/repo.go b/repo.go index 07eb5ea..50eeb25 100644 --- a/repo.go +++ b/repo.go @@ -144,6 +144,9 @@ func (r *Repo) Restore(destination string) { if err != nil { log.Printf("Error storing file content for '%s', written %d/%d bytes: %s\n", filePath, n, file.Size, err) } + if err := f.Close(); err != nil { + log.Printf("Error closing restored file '%s': %s\n", filePath, err) + } } } @@ -276,6 +279,9 @@ func (r *Repo) LoadChunkContent(id *ChunkId) *bytes.Reader { if err != nil { log.Panicf("Could not read from chunk '%s': %s\n", path, err) } + if err = f.Close(); err != nil { + log.Printf("Could not close chunk '%s': %s\n", path, err) + } r.chunkCache.Set(id, value) } return bytes.NewReader(value) -- cgit v1.2.3