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.
This commit is contained in:
Michael Eischer 2023-07-07 22:42:39 +02:00
parent 9cd85d5956
commit 307aeb6849
1 changed files with 5 additions and 0 deletions

View File

@ -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)
}