From 6c2b2a58adf7e13b29732c1e0a5f6cbde3c05cdc Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 22 Dec 2017 18:34:17 +0100 Subject: [PATCH] backend: Retry deletes --- internal/backend/backend_retry.go | 9 ++++++++- internal/restic/backend.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/backend/backend_retry.go b/internal/backend/backend_retry.go index 45a30e468..dcbf27e4d 100644 --- a/internal/backend/backend_retry.go +++ b/internal/backend/backend_retry.go @@ -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) + }) +} diff --git a/internal/restic/backend.go b/internal/restic/backend.go index 906ebf6d7..9174b5522 100644 --- a/internal/restic/backend.go +++ b/internal/restic/backend.go @@ -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