azure/b2/gs/s3/swift: adapt cloud backend
This commit is contained in:
parent
e793c002ec
commit
d40f23e716
5 changed files with 116 additions and 3 deletions
|
@ -167,6 +167,20 @@ func (be *Backend) IsNotExist(err error) bool {
|
|||
return bloberror.HasCode(err, bloberror.BlobNotFound)
|
||||
}
|
||||
|
||||
func (be *Backend) IsPermanentError(err error) bool {
|
||||
if be.IsNotExist(err) {
|
||||
return true
|
||||
}
|
||||
|
||||
var aerr *azcore.ResponseError
|
||||
if errors.As(err, &aerr) {
|
||||
if aerr.StatusCode == http.StatusRequestedRangeNotSatisfiable || aerr.StatusCode == http.StatusUnauthorized || aerr.StatusCode == http.StatusForbidden {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Join combines path components with slashes.
|
||||
func (be *Backend) Join(p ...string) string {
|
||||
return path.Join(p...)
|
||||
|
@ -313,6 +327,11 @@ func (be *Backend) openReader(ctx context.Context, h backend.Handle, length int,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if length > 0 && (resp.ContentLength == nil || *resp.ContentLength != int64(length)) {
|
||||
_ = resp.Body.Close()
|
||||
return nil, &azcore.ResponseError{ErrorCode: "restic-file-too-short", StatusCode: http.StatusRequestedRangeNotSatisfiable}
|
||||
}
|
||||
|
||||
return resp.Body, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue