From 19725954ee4d88dd5da4e7d1dd4744bb5b4a3b44 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 4 Oct 2018 14:30:07 +0200 Subject: [PATCH] cache: Recheck before downloading --- internal/cache/backend.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/cache/backend.go b/internal/cache/backend.go index 6aaee64ce..7048fd4d4 100644 --- a/internal/cache/backend.go +++ b/internal/cache/backend.go @@ -106,6 +106,11 @@ func (b *Backend) cacheFile(ctx context.Context, h restic.Handle) error { return nil } + // test again, maybe the file was cached in the meantime + if b.Cache.Has(h) { + return nil + } + err := b.Backend.Load(ctx, h, 0, 0, func(rd io.Reader) error { return b.Cache.Save(h, rd) }) @@ -122,7 +127,7 @@ func (b *Backend) cacheFile(ctx context.Context, h restic.Handle) error { delete(b.inProgress, h) b.inProgressMutex.Unlock() - return err + return nil } // loadFromCacheOrDelegate will try to load the file from the cache, and fall