mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #2632 from lapshin-vitaly/s3api_errors
add s3api error for copy in file, not directory
This commit is contained in:
commit
247bbabda5
|
@ -436,10 +436,14 @@ func setEtag(w http.ResponseWriter, etag string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func filerErrorToS3Error(errString string) s3err.ErrorCode {
|
func filerErrorToS3Error(errString string) s3err.ErrorCode {
|
||||||
if strings.HasPrefix(errString, "existing ") && strings.HasSuffix(errString, "is a directory") {
|
switch {
|
||||||
|
case strings.HasPrefix(errString, "existing ") && strings.HasSuffix(errString, "is a directory"):
|
||||||
return s3err.ErrExistingObjectIsDirectory
|
return s3err.ErrExistingObjectIsDirectory
|
||||||
|
case strings.HasSuffix(errString, "is a file"):
|
||||||
|
return s3err.ErrExistingObjectIsFile
|
||||||
|
default:
|
||||||
|
return s3err.ErrInternalError
|
||||||
}
|
}
|
||||||
return s3err.ErrInternalError
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s3a *S3ApiServer) maybeAddFilerJwtAuthorization(r *http.Request, isWrite bool) {
|
func (s3a *S3ApiServer) maybeAddFilerJwtAuthorization(r *http.Request, isWrite bool) {
|
||||||
|
|
|
@ -101,6 +101,7 @@ const (
|
||||||
ErrPreconditionFailed
|
ErrPreconditionFailed
|
||||||
|
|
||||||
ErrExistingObjectIsDirectory
|
ErrExistingObjectIsDirectory
|
||||||
|
ErrExistingObjectIsFile
|
||||||
)
|
)
|
||||||
|
|
||||||
// error code to APIError structure, these fields carry respective
|
// error code to APIError structure, these fields carry respective
|
||||||
|
@ -383,6 +384,11 @@ var errorCodeResponse = map[ErrorCode]APIError{
|
||||||
Description: "Existing Object is a directory.",
|
Description: "Existing Object is a directory.",
|
||||||
HTTPStatusCode: http.StatusConflict,
|
HTTPStatusCode: http.StatusConflict,
|
||||||
},
|
},
|
||||||
|
ErrExistingObjectIsFile: {
|
||||||
|
Code: "ExistingObjectIsFile",
|
||||||
|
Description: "Existing Object is a file.",
|
||||||
|
HTTPStatusCode: http.StatusConflict,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAPIError provides API Error for input API error code.
|
// GetAPIError provides API Error for input API error code.
|
||||||
|
|
Loading…
Reference in a new issue