From 307aeb6849a79748349a661f3318b9907506623d Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 7 Jul 2023 22:42:39 +0200 Subject: [PATCH] rest: Don't return error if listing non-existent directory When transferring a repository from S3 to, for example, a local disk then all empty folders will be missing. When saving files, the missing intermediate folders are created automatically. Therefore, missing directories can be ignored by the `List()` operation. --- internal/backend/rest/rest.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/backend/rest/rest.go b/internal/backend/rest/rest.go index 8391df681..378d12c9d 100644 --- a/internal/backend/rest/rest.go +++ b/internal/backend/rest/rest.go @@ -327,6 +327,11 @@ func (b *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.Fi return errors.Wrap(err, "List") } + if resp.StatusCode == http.StatusNotFound { + // ignore missing directories + return nil + } + if resp.StatusCode != 200 { return errors.Errorf("List failed, server response: %v (%v)", resp.Status, resp.StatusCode) }