mirror of
https://github.com/octoleo/restic.git
synced 2025-01-31 02:48:30 +00:00
Fix failure to detect some legacy s3 repos
Sometimes s3 listobjects for a directory includes an entry for that directory. The restic s3 backend doesn't expect that and returns an error. Symptom is: ReadDir: invalid key name restic/key/, removing prefix restic/key/ yielded empty string I'm not sure when s3 does that; I'm unable to reproduce it myself. But in any case, it seems correct to ignore that when it happens. Fixes #1068
This commit is contained in:
parent
7507a658ac
commit
944fc857eb
@ -172,8 +172,9 @@ func (be *Backend) ReadDir(dir string) (list []os.FileInfo, err error) {
|
||||
}
|
||||
|
||||
name := strings.TrimPrefix(obj.Key, dir)
|
||||
// Sometimes s3 returns an entry for the dir itself. Ignore it.
|
||||
if name == "" {
|
||||
return nil, errors.Errorf("invalid key name %v, removing prefix %v yielded empty string", obj.Key, dir)
|
||||
continue
|
||||
}
|
||||
entry := fileInfo{
|
||||
name: name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user