mirror of
https://github.com/restic/restic.git
synced 2025-12-04 03:38:25 +00:00
cache: Drop cache entry if it cannot be processed
Failing to process data requested from the cache usually indicates a problem with the returned data. Assume that the cache entry is somehow damaged and retry downloading it once.
This commit is contained in:
7
internal/cache/backend.go
vendored
7
internal/cache/backend.go
vendored
@@ -161,7 +161,12 @@ func (b *Backend) Load(ctx context.Context, h restic.Handle, length int, offset
|
||||
// try loading from cache without checking that the handle is actually cached
|
||||
inCache, err := b.loadFromCache(ctx, h, length, offset, consumer)
|
||||
if inCache {
|
||||
return err
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// drop from cache and retry once
|
||||
_ = b.Cache.remove(h)
|
||||
}
|
||||
debug.Log("error loading %v from cache: %v", h, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user