mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 12:55:18 +00:00
Merge pull request #4400 from MichaelEischer/rest-handle-missing-dirs
rest: Ignore missing directories
This commit is contained in:
commit
594689db32
8
changelog/unreleased/pull-4400
Normal file
8
changelog/unreleased/pull-4400
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Bugfix: Ignore missing folders in REST backend
|
||||||
|
|
||||||
|
If a repository accessed via the REST backend was missing folders, then restic
|
||||||
|
would fail with an error while trying to list the data in the repository. This
|
||||||
|
has been fixed.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/4400
|
||||||
|
https://github.com/restic/rest-server/issues/235
|
@ -147,7 +147,7 @@ func (b *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRea
|
|||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return errors.Errorf("server response unexpected: %v (%v)", resp.Status, resp.StatusCode)
|
return errors.Errorf("server response unexpected: %v (%v)", resp.Status, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ func (b *Backend) openReader(ctx context.Context, h restic.Handle, length int, o
|
|||||||
return nil, ¬ExistError{h}
|
return nil, ¬ExistError{h}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 && resp.StatusCode != 206 {
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
|
||||||
_ = resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
return nil, errors.Errorf("unexpected HTTP response (%v): %v", resp.StatusCode, resp.Status)
|
return nil, errors.Errorf("unexpected HTTP response (%v): %v", resp.StatusCode, resp.Status)
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ func (b *Backend) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, e
|
|||||||
return restic.FileInfo{}, ¬ExistError{h}
|
return restic.FileInfo{}, ¬ExistError{h}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return restic.FileInfo{}, errors.Errorf("unexpected HTTP response (%v): %v", resp.StatusCode, resp.Status)
|
return restic.FileInfo{}, errors.Errorf("unexpected HTTP response (%v): %v", resp.StatusCode, resp.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ func (b *Backend) Remove(ctx context.Context, h restic.Handle) error {
|
|||||||
return ¬ExistError{h}
|
return ¬ExistError{h}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return errors.Errorf("blob not removed, server response: %v (%v)", resp.Status, resp.StatusCode)
|
return errors.Errorf("blob not removed, server response: %v (%v)", resp.Status, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +327,12 @@ func (b *Backend) List(ctx context.Context, t restic.FileType, fn func(restic.Fi
|
|||||||
return errors.Wrap(err, "List")
|
return errors.Wrap(err, "List")
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
|
// ignore missing directories
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
return errors.Errorf("List failed, server response: %v (%v)", resp.Status, resp.StatusCode)
|
return errors.Errorf("List failed, server response: %v (%v)", resp.Status, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user