From 2f9975c76c9e009b2f5c48887aa82f4e96bfa105 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 30 Aug 2016 03:42:37 -0700 Subject: [PATCH] notifications: GetObjectInfo() later if bucket notifications are set. (#2575) --- cmd/bucket-handlers.go | 16 +++++++++------- cmd/object-handlers.go | 28 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 4cff69254..4115e62bf 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -360,18 +360,20 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h ETag: md5Sum, }) + // Set common headers. setCommonHeaders(w) + // Write successful response. writeSuccessResponse(w, encodedSuccessResponse) - // Fetch object info for notifications. - objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object) - if err != nil { - errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object)) - return - } - if eventN.IsBucketNotificationSet(bucket) { + // Fetch object info for notifications. + objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object) + if err != nil { + errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object)) + return + } + // Notify object created event. eventNotify(eventData{ Type: ObjectCreatedPost, diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 019bb5d3a..fbaa7db9f 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -454,14 +454,14 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req } writeSuccessResponse(w, nil) - // Fetch object info for notifications. - objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object) - if err != nil { - errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object)) - return - } - if eventN.IsBucketNotificationSet(bucket) { + // Fetch object info for notifications. + objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object) + if err != nil { + errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object)) + return + } + // Notify object created event. eventNotify(eventData{ Type: ObjectCreatedPut, @@ -795,14 +795,14 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite w.Write(encodedSuccessResponse) w.(http.Flusher).Flush() - // Fetch object info for notifications. - objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object) - if err != nil { - errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object)) - return - } - if eventN.IsBucketNotificationSet(bucket) { + // Fetch object info for notifications. + objInfo, err := api.ObjectAPI.GetObjectInfo(bucket, object) + if err != nil { + errorIf(err, "Unable to fetch object info for \"%s\"", path.Join(bucket, object)) + return + } + // Notify object created event. eventNotify(eventData{ Type: ObjectCreatedCompleteMultipartUpload,