From 1b74ce39242cdf559824f625f2e73d3d13410cf5 Mon Sep 17 00:00:00 2001 From: poornas Date: Sun, 20 Oct 2019 23:48:19 -0700 Subject: [PATCH] Ensure actual object size is sent in notification (#8418) Fixes: #8407 --- cmd/notification.go | 9 +++++++++ cmd/object-handlers.go | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/notification.go b/cmd/notification.go index 869465ed6..80254bd9c 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1191,6 +1191,15 @@ func (args eventArgs) ToEvent() event.Event { func sendEvent(args eventArgs) { // remove sensitive encryption entries in metadata. + switch { + case crypto.IsEncrypted(args.Object.UserDefined): + if totalObjectSize, err := args.Object.DecryptedSize(); err == nil { + args.Object.Size = totalObjectSize + } + case args.Object.IsCompressed(): + args.Object.Size = args.Object.GetActualSize() + } + crypto.RemoveSensitiveEntries(args.Object.UserDefined) crypto.RemoveInternalEntries(args.Object.UserDefined) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 8c035b329..26f4edf5a 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -1272,7 +1272,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req if objectAPI.IsEncryptionSupported() { if crypto.IsEncrypted(objInfo.UserDefined) { - objInfo.Size, _ = objInfo.DecryptedSize() switch { case crypto.S3.IsEncrypted(objInfo.UserDefined): w.Header().Set(crypto.SSEHeader, crypto.SSEAlgorithmAES256) @@ -2337,13 +2336,6 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite // Write success response. writeSuccessResponseXML(w, encodedSuccessResponse) - // Get host and port from Request.RemoteAddr. - if objectAPI.IsEncryptionSupported() { - if crypto.IsEncrypted(objInfo.UserDefined) { - objInfo.Size, _ = objInfo.DecryptedSize() - } - } - // Notify object created event. sendEvent(eventArgs{ EventName: event.ObjectCreatedCompleteMultipartUpload,