rclone: Workaround for incorrect "not found" errors while listing files

rclone returns a "not found" error if an internal error occurs while
listing a folder. Ignoring this error lets restic erroneously think that
there are no files, which can cause `prune` to wipe the whole
repository.
This commit is contained in:
Michael Eischer committed 2024-01-09 18:28:17 +01:00
1 parent ec0fb46f6c
commit e4bbde7036
2 files changed
+18 -2

No files matched your search

+7 -2
View File
@@ -328,8 +328,13 @@ func (b *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.Fi
}
if resp.StatusCode == http.StatusNotFound {
// ignore missing directories
return nil
if !strings.HasPrefix(resp.Header.Get("Server"), "rclone/") {
// 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 {