From 80558e839d222010d688623811f3d679dee078be Mon Sep 17 00:00:00 2001 From: poornas Date: Thu, 12 Dec 2019 15:11:27 -0800 Subject: [PATCH] Clear cache if reverting to backend (#8637) Clear cached entry before reverting to backend for encrypted objects or those under retention to avoid stale objects remaining in cache. --- cmd/disk-cache.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index 9f2a89e7e..be69a999f 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -585,12 +585,14 @@ func (c *cacheObjects) PutObject(ctx context.Context, bucket, object string, r * return putObjectFn(ctx, bucket, object, r, opts) } if opts.ServerSideEncryption != nil { + dcache.Delete(ctx, bucket, object) return putObjectFn(ctx, bucket, object, r, opts) } // skip cache for objects with locks objRetention := getObjectRetentionMeta(opts.UserDefined) if objRetention.Mode == Governance || objRetention.Mode == Compliance { + dcache.Delete(ctx, bucket, object) return putObjectFn(ctx, bucket, object, r, opts) }