forked from TrueCloudLab/restic
Merge pull request #4618 from MichaelEischer/workaround-rclone-list-errors
rclone: Workaround for incorrect "not found" errors while listing files
This commit is contained in:
commit
7b2de84763
2 changed files with 18 additions and 2 deletions
11
changelog/unreleased/issue-4612
Normal file
11
changelog/unreleased/issue-4612
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Bugfix: Improve error handling for `rclone` backend
|
||||||
|
|
||||||
|
Since restic 0.16.0, if rclone encountered an error while listing files,
|
||||||
|
this could in rare circumstances cause restic to assume that there are no
|
||||||
|
files. Although unlikely, this situation could result in data loss if it
|
||||||
|
were to happen right when the `prune` command is listing existing snapshots.
|
||||||
|
|
||||||
|
Error handling has now been improved to detect and work around this case.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issues/4612
|
||||||
|
https://github.com/restic/restic/pull/4618
|
|
@ -328,8 +328,13 @@ func (b *Backend) List(ctx context.Context, t backend.FileType, fn func(backend.
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusNotFound {
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
// ignore missing directories
|
if !strings.HasPrefix(resp.Header.Get("Server"), "rclone/") {
|
||||||
return nil
|
// ignore missing directories, unless the server is rclone. rclone
|
||||||
|
// already ignores missing directories, but misuses "not found" to
|
||||||
|
// report certain internal errors, see
|
||||||
|
// https://github.com/rclone/rclone/pull/7550 for details.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
|
Loading…
Reference in a new issue