backend: Retry deletes

This commit is contained in:
Alexander Neumann 2017-12-22 18:34:17 +01:00
parent b80b68dcb3
commit 6c2b2a58ad
2 changed files with 9 additions and 2 deletions

View file

@ -74,7 +74,7 @@ func (be *RetryBackend) Save(ctx context.Context, h restic.Handle, rd io.Reader)
}
debug.Log("Save(%v) failed with error, removing file: %v", h, err)
rerr := be.Remove(ctx, h)
rerr := be.Backend.Remove(ctx, h)
if rerr != nil {
debug.Log("Remove(%v) returned error: %v", h, err)
}
@ -110,3 +110,10 @@ func (be *RetryBackend) Stat(ctx context.Context, h restic.Handle) (fi restic.Fi
})
return fi, err
}
// Remove removes a File with type t and name.
func (be *RetryBackend) Remove(ctx context.Context, h restic.Handle) (err error) {
return be.retry(ctx, fmt.Sprintf("Remove(%v)", h), func() error {
return be.Backend.Remove(ctx, h)
})
}

View file

@ -14,7 +14,7 @@ type Backend interface {
// Test a boolean value whether a File with the name and type exists.
Test(ctx context.Context, h Handle) (bool, error)
// Remove removes a File with type t and name.
// Remove removes a File described by h.
Remove(ctx context.Context, h Handle) error
// Close the backend