diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-02-04 22:34:34 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-04 22:34:34 -0800 |
| commit | 247bbabda5ce934a77f4cb705620d663d5cdcfe4 (patch) | |
| tree | 545e5750512e9053f781945373f022bcc58f8511 | |
| parent | ced3b89395524f3d6de429d338be3714b0815f1a (diff) | |
| parent | 6bdc274d4db8063db44bb7b71ef7a1f354c07ee1 (diff) | |
| download | seaweedfs-247bbabda5ce934a77f4cb705620d663d5cdcfe4.tar.xz seaweedfs-247bbabda5ce934a77f4cb705620d663d5cdcfe4.zip | |
Merge pull request #2632 from lapshin-vitaly/s3api_errors
add s3api error for copy in file, not directory
| -rw-r--r-- | weed/s3api/s3api_object_handlers.go | 8 | ||||
| -rw-r--r-- | weed/s3api/s3err/s3api_errors.go | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index fd2a0e6bd..f454bfad2 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -436,10 +436,14 @@ func setEtag(w http.ResponseWriter, etag string) { } 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 + 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) { diff --git a/weed/s3api/s3err/s3api_errors.go b/weed/s3api/s3err/s3api_errors.go index 8d02f15b1..f4a83d979 100644 --- a/weed/s3api/s3err/s3api_errors.go +++ b/weed/s3api/s3err/s3api_errors.go @@ -101,6 +101,7 @@ const ( ErrPreconditionFailed ErrExistingObjectIsDirectory + ErrExistingObjectIsFile ) // error code to APIError structure, these fields carry respective @@ -383,6 +384,11 @@ var errorCodeResponse = map[ErrorCode]APIError{ Description: "Existing Object is a directory.", HTTPStatusCode: http.StatusConflict, }, + ErrExistingObjectIsFile: { + Code: "ExistingObjectIsFile", + Description: "Existing Object is a file.", + HTTPStatusCode: http.StatusConflict, + }, } // GetAPIError provides API Error for input API error code. |
