From 2c096c569f2e57408ae657c669dc5740cba7a603 Mon Sep 17 00:00:00 2001 From: poornas Date: Thu, 18 Apr 2019 13:53:22 -0700 Subject: [PATCH] do not try to delete non-existent object in cache (#7560) handle cache cleanup correctly when backend object was deleted. Fixes: #7558 --- cmd/disk-cache.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index 3f02be045..a6d7fd4e6 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -200,9 +200,12 @@ func (c cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string, return cacheReader, nil } else if err != nil { if _, ok := err.(ObjectNotFound); ok { - cacheReader.Close() - // Delete cached entry if backend object was deleted. - dcache.Delete(ctx, bucket, object) + if cacheErr == nil { + cacheReader.Close() + // Delete cached entry if backend object + // was deleted. + dcache.Delete(ctx, bucket, object) + } } return nil, err }