diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2020-09-24 18:21:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-24 18:21:34 -0700 |
| commit | 043b0631369bec00b33eb53cdf2cdef3eced006c (patch) | |
| tree | 72e1b320c3487aa5f6cb3cd5fc849bfd94108ec8 /weed/s3api/s3api_object_handlers.go | |
| parent | dbf5327b9874bf7137eb53cbe04cd362efeb864c (diff) | |
| parent | 48c578410fea2128f81356250b2cd9d56074d878 (diff) | |
| download | seaweedfs-043b0631369bec00b33eb53cdf2cdef3eced006c.tar.xz seaweedfs-043b0631369bec00b33eb53cdf2cdef3eced006c.zip | |
Merge pull request #1482 from hilimd/master
Fix: s3 delete object
Diffstat (limited to 'weed/s3api/s3api_object_handlers.go')
| -rw-r--r-- | weed/s3api/s3api_object_handlers.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/weed/s3api/s3api_object_handlers.go b/weed/s3api/s3api_object_handlers.go index ea3cb47dd..13fae72a3 100644 --- a/weed/s3api/s3api_object_handlers.go +++ b/weed/s3api/s3api_object_handlers.go @@ -112,6 +112,12 @@ func (s3a *S3ApiServer) DeleteObjectHandler(w http.ResponseWriter, r *http.Reque bucket, object := getBucketAndObject(r) + response, _ := s3a.listFilerEntries(bucket, object, 1, "", "/") + if len(response.Contents) != 0 && strings.HasSuffix(object, "/") { + w.WriteHeader(http.StatusNoContent) + return + } + destUrl := fmt.Sprintf("http://%s%s/%s%s?recursive=true", s3a.option.Filer, s3a.option.BucketsPath, bucket, object) @@ -121,7 +127,6 @@ func (s3a *S3ApiServer) DeleteObjectHandler(w http.ResponseWriter, r *http.Reque } w.WriteHeader(http.StatusNoContent) }) - } // / ObjectIdentifier carries key name for the object to delete. @@ -178,6 +183,11 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { for _, object := range deleteObjects.Objects { + response, _ := s3a.listFilerEntries(bucket, object.ObjectName, 1, "", "/") + if len(response.Contents) != 0 && strings.HasSuffix(object.ObjectName, "/") { + continue + } + lastSeparator := strings.LastIndex(object.ObjectName, "/") parentDirectoryPath, entryName, isDeleteData, isRecursive := "/", object.ObjectName, true, true if lastSeparator > 0 && lastSeparator+1 < len(object.ObjectName) { |
