From 7ae60a6d10fad462634875698d5f7f16846fe8c6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 13 Jul 2015 19:29:32 -0700 Subject: [PATCH] For missing parts reply back as InvalidPart{} --- pkg/donut/errors.go | 7 +++++++ pkg/donut/multipart.go | 2 +- pkg/server/api/object-handlers.go | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/donut/errors.go b/pkg/donut/errors.go index 5aec5e627..f75d774bc 100644 --- a/pkg/donut/errors.go +++ b/pkg/donut/errors.go @@ -335,6 +335,13 @@ func (e MissingDateHeader) Error() string { return "Missing date header" } +// InvalidPart One or more of the specified parts could not be found +type InvalidPart struct{} + +func (e InvalidPart) Error() string { + return "One or more of the specified parts could not be found" +} + // InvalidPartOrder parts are not ordered as Requested type InvalidPartOrder struct { UploadID string diff --git a/pkg/donut/multipart.go b/pkg/donut/multipart.go index da9e3f1bf..901133eed 100644 --- a/pkg/donut/multipart.go +++ b/pkg/donut/multipart.go @@ -286,7 +286,7 @@ func (donut API) CompleteMultipartUpload(bucket, key, uploadID string, data io.R object, ok := donut.multiPartObjects[uploadID].Get(parts.Part[i].PartNumber) if ok == false { donut.lock.Unlock() - return ObjectMetadata{}, iodine.New(errors.New("missing part: "+strconv.Itoa(parts.Part[i].PartNumber)), nil) + return ObjectMetadata{}, iodine.New(InvalidPart{}, nil) } size += int64(len(object)) calcMD5Bytes := md5.Sum(object) diff --git a/pkg/server/api/object-handlers.go b/pkg/server/api/object-handlers.go index 5e9c3f2a7..d8a2b6a9c 100644 --- a/pkg/server/api/object-handlers.go +++ b/pkg/server/api/object-handlers.go @@ -558,6 +558,8 @@ func (api Minio) CompleteMultipartUploadHandler(w http.ResponseWriter, req *http } case donut.InvalidUploadID: writeErrorResponse(w, req, NoSuchUpload, acceptsContentType, req.URL.Path) + case donut.InvalidPart: + writeErrorResponse(w, req, InvalidPart, acceptsContentType, req.URL.Path) case donut.InvalidPartOrder: writeErrorResponse(w, req, InvalidPartOrder, acceptsContentType, req.URL.Path) case donut.MissingDateHeader: