From 301de169e975dfc4fd84c702c7b87e91c381e40d Mon Sep 17 00:00:00 2001 From: Erkki Eilonen Date: Mon, 25 May 2020 14:17:03 +0700 Subject: [PATCH] in cache build ranges metadata as needed (#9698) --- cmd/disk-cache-backend.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/disk-cache-backend.go b/cmd/disk-cache-backend.go index 612e81a33..6eb8cd4a3 100644 --- a/cmd/disk-cache-backend.go +++ b/cmd/disk-cache-backend.go @@ -498,10 +498,14 @@ func (c *diskCache) saveMetadata(ctx context.Context, bucket, object string, met } // increment hits if rs != nil { - if m.Ranges == nil { - m.Ranges = make(map[string]string) + // rsFileName gets set by putRange. Check for blank values here + // coming from other code paths that set rs only (eg initial creation or hit increment). + if rsFileName != "" { + if m.Ranges == nil { + m.Ranges = make(map[string]string) + } + m.Ranges[rs.String(actualSize)] = rsFileName } - m.Ranges[rs.String(actualSize)] = rsFileName } else { // this is necessary cleanup of range files if entire object is cached. for _, f := range m.Ranges {