diff --git a/cmd/erasure-server-pool.go b/cmd/erasure-server-pool.go index 4f0055ad8..87ddc6c0b 100644 --- a/cmd/erasure-server-pool.go +++ b/cmd/erasure-server-pool.go @@ -1160,11 +1160,6 @@ func (z *erasureServerPools) ListObjects(ctx context.Context, bucket, prefix, ma // Automatically remove the object/version is an expiry lifecycle rule can be applied lc, _ := globalLifecycleSys.Get(bucket) - if lc != nil { - if !lc.HasActiveRules(prefix, true) { - lc = nil - } - } if len(prefix) > 0 && maxKeys == 1 && delimiter == "" && marker == "" { // Optimization for certain applications like @@ -1180,6 +1175,8 @@ func (z *erasureServerPools) ListObjects(ctx context.Context, bucket, prefix, ma action := evalActionFromLifecycle(ctx, *lc, objInfo, false) switch action { case lifecycle.DeleteVersionAction, lifecycle.DeleteAction: + fallthrough + case lifecycle.DeleteRestoredAction, lifecycle.DeleteRestoredVersionAction: return loi, nil } } @@ -1196,6 +1193,7 @@ func (z *erasureServerPools) ListObjects(ctx context.Context, bucket, prefix, ma Marker: marker, InclDeleted: false, AskDisks: globalAPIConfig.getListQuorum(), + Lifecycle: lc, } merged, err := z.listPath(ctx, &opts) diff --git a/cmd/metacache-server-pool.go b/cmd/metacache-server-pool.go index 19a5cead6..b443167f9 100644 --- a/cmd/metacache-server-pool.go +++ b/cmd/metacache-server-pool.go @@ -291,9 +291,9 @@ func (z *erasureServerPools) listMerged(ctx context.Context, o listPathOptions, mu.Unlock() // Do lifecycle filtering. - if o.lcFilter != nil { + if o.Lifecycle != nil { filterIn := make(chan metaCacheEntry, 10) - go filterLifeCycle(ctx, o.Bucket, o.lcFilter, filterIn, results) + go filterLifeCycle(ctx, o.Bucket, o.Lifecycle, filterIn, results) // Replace results. results = filterIn } @@ -381,6 +381,8 @@ func filterLifeCycle(ctx context.Context, bucket string, lc *lifecycle.Lifecycle action := evalActionFromLifecycle(ctx, *lc, objInfo, false) switch action { case lifecycle.DeleteVersionAction, lifecycle.DeleteAction: + fallthrough + case lifecycle.DeleteRestoredAction, lifecycle.DeleteRestoredVersionAction: // Skip this entry. continue } diff --git a/cmd/metacache-set.go b/cmd/metacache-set.go index c427bbb78..a9a003686 100644 --- a/cmd/metacache-set.go +++ b/cmd/metacache-set.go @@ -93,13 +93,13 @@ type listPathOptions struct { // Versioned is this a ListObjectVersions call. Versioned bool - // pool and set of where the cache is located. - pool, set int - - // lcFilter performs filtering based on lifecycle. + // Lifecycle performs filtering based on lifecycle. // This will filter out objects if the most recent version should be deleted by lifecycle. // Is not transferred across request calls. - lcFilter *lifecycle.Lifecycle + Lifecycle *lifecycle.Lifecycle + + // pool and set of where the cache is located. + pool, set int } func init() {