From 360f3f93358ba2f1a2b8ae7d5ccb0a9fb8ea8579 Mon Sep 17 00:00:00 2001 From: Praveen raj Mani Date: Sun, 1 Jul 2018 11:05:43 +0530 Subject: [PATCH] Checking the existence of the bucket in DeleteObjectHandler (#6085) Fixes #6077 --- cmd/object-handlers.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 3a185aafe..d42158571 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -31,6 +31,7 @@ import ( "sort" "strconv" + etcd "github.com/coreos/etcd/client" "github.com/gorilla/mux" miniogo "github.com/minio/minio-go" "github.com/minio/minio/cmd/logger" @@ -1539,6 +1540,27 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http. return } + if globalDNSConfig != nil { + _, err := globalDNSConfig.Get(bucket) + if err != nil { + if etcd.IsKeyNotFound(err) || err == dns.ErrNoEntriesFound { + writeErrorResponse(w, ErrNoSuchBucket, r.URL) + } else { + writeErrorResponse(w, toAPIErrorCode(err), r.URL) + } + return + } + } else { + getBucketInfo := objectAPI.GetBucketInfo + if api.CacheAPI() != nil { + getBucketInfo = api.CacheAPI().GetBucketInfo + } + if _, err := getBucketInfo(ctx, bucket); err != nil { + writeErrorResponse(w, toAPIErrorCode(err), r.URL) + return + } + } + // http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html // Ignore delete object errors while replying to client, since we are // suppposed to reply only 204. Additionally log the error for