From 26ed9e81b173521d9c32228329ad061a9a90b60f Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Tue, 5 Nov 2019 00:52:03 +0100 Subject: [PATCH] lifecycle: Send delete notification when deleting objects (#8416) --- cmd/daily-lifecycle-ops.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cmd/daily-lifecycle-ops.go b/cmd/daily-lifecycle-ops.go index 0d99fa638..2afa65be4 100644 --- a/cmd/daily-lifecycle-ops.go +++ b/cmd/daily-lifecycle-ops.go @@ -21,6 +21,7 @@ import ( "time" "github.com/minio/minio/cmd/logger" + "github.com/minio/minio/pkg/event" "github.com/minio/minio/pkg/lifecycle" ) @@ -150,8 +151,29 @@ func lifecycleRound(ctx context.Context, objAPI ObjectLayer) error { // Do nothing, for now. } } + // Deletes a list of objects. - objAPI.DeleteObjects(ctx, bucket.Name, objects) + deleteErrs, err := objAPI.DeleteObjects(ctx, bucket.Name, objects) + if err != nil { + logger.LogIf(ctx, err) + } else { + for i := range deleteErrs { + if deleteErrs[i] != nil { + logger.LogIf(ctx, deleteErrs[i]) + continue + } + // Notify object deleted event. + sendEvent(eventArgs{ + EventName: event.ObjectRemovedDelete, + BucketName: bucket.Name, + Object: ObjectInfo{ + Name: objects[i], + }, + Host: "Internal: [ILM-EXPIRY]", + }) + } + } + if !res.IsTruncated { // We are done here, proceed to next bucket. break