2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-16 01:57:10 +00:00

cache: In case of an error, fall back backend

This commit is contained in:
Alexander Neumann 2017-09-24 23:06:54 +02:00
parent db5ec5d876
commit 240c4cf2fd

View File

@ -105,7 +105,11 @@ func (b *Backend) cacheFile(ctx context.Context, h restic.Handle) error {
func (b *Backend) Load(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error) { func (b *Backend) Load(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error) {
if b.Cache.Has(h) { if b.Cache.Has(h) {
debug.Log("Load(%v, %v, %v) from cache", h, length, offset) debug.Log("Load(%v, %v, %v) from cache", h, length, offset)
return b.Cache.Load(h, length, offset) rd, err := b.Cache.Load(h, length, offset)
if err == nil {
return rd, nil
}
debug.Log("error loading %v from cache: %v", h, err)
} }
// partial file requested // partial file requested