mirror of
https://github.com/restic/restic.git
synced 2025-08-23 09:47:42 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user