diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index a75e77505..a5c961ab2 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -618,14 +618,6 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, } - // Clean up transitioned objects from remote tier - for _, os := range oss { - if os == nil { // skip objects that weren't deleted due to invalid versionID etc. - continue - } - logger.LogIf(ctx, os.Sweep()) - } - // Notify deleted event for objects. for _, dobj := range deletedObjects { eventName := event.ObjectRemovedDelete @@ -650,6 +642,14 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter, Host: handlers.GetSourceIP(r), }) } + + // Clean up transitioned objects from remote tier + for _, os := range oss { + if os == nil { // skip objects that weren't deleted due to invalid versionID etc. + continue + } + logger.LogIf(ctx, os.Sweep()) + } } // PutBucketHandler - PUT Bucket diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 4b1662a17..2fc524d6c 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -1395,8 +1395,9 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re } // Remove the transitioned object whose object version is being overwritten. - logger.LogIf(ctx, os.Sweep()) + defer logger.LogIf(ctx, os.Sweep()) } + objInfo.ETag = getDecryptedETag(r.Header, objInfo, false) response := generateCopyObjectResponse(objInfo.ETag, objInfo.ModTime) encodedSuccessResponse := encodeResponse(response) @@ -1684,11 +1685,11 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req // Ensure that metadata does not contain sensitive information crypto.RemoveSensitiveEntries(metadata) - oc := newObjSweeper(bucket, object) + os := newObjSweeper(bucket, object) // Get appropriate object info to identify the remote object to delete - goiOpts := oc.GetOpts() + goiOpts := os.GetOpts() if goi, gerr := getObjectInfo(ctx, bucket, object, goiOpts); gerr == nil { - oc.SetTransitionState(goi) + os.SetTransitionState(goi) } // Create the object.. @@ -1735,9 +1736,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req scheduleReplication(ctx, objInfo.Clone(), objectAPI, sync, replication.ObjectReplicationType) } - // Remove the transitioned object whose object version is being overwritten. - logger.LogIf(ctx, oc.Sweep()) - setPutObjHeaders(w, objInfo, false) writeSuccessResponseHeadersOnly(w) @@ -1752,6 +1750,9 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req UserAgent: r.UserAgent(), Host: handlers.GetSourceIP(r), }) + + // Remove the transitioned object whose object version is being overwritten. + logger.LogIf(ctx, os.Sweep()) } // PutObjectExtractHandler - PUT Object extract is an extended API @@ -3118,9 +3119,6 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite scheduleReplication(ctx, objInfo.Clone(), objectAPI, sync, replication.ObjectReplicationType) } - // Remove the transitioned object whose object version is being overwritten. - logger.LogIf(ctx, os.Sweep()) - // Write success response. writeSuccessResponseXML(w, encodedSuccessResponse) @@ -3134,6 +3132,9 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite UserAgent: r.UserAgent(), Host: handlers.GetSourceIP(r), }) + + // Remove the transitioned object whose object version is being overwritten. + logger.LogIf(ctx, os.Sweep()) } /// Delete objectAPIHandlers