do not try to delete non-existent object in cache (#7560)

handle cache cleanup correctly when backend object was deleted.

Fixes: #7558
This commit is contained in:
poornas 2019-04-18 13:53:22 -07:00 committed by kannappanr
parent 816459d10f
commit 2c096c569f

View File

@ -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
}