From 013773065c522ac99595f17ef0585db7f94557b7 Mon Sep 17 00:00:00 2001 From: poornas Date: Wed, 12 Feb 2020 19:19:32 -0800 Subject: [PATCH] Save metadata correctly in cache.json on PUT (#8985) fixes #8979 --- cmd/disk-cache-backend.go | 2 +- cmd/disk-cache.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/disk-cache-backend.go b/cmd/disk-cache-backend.go index ff6133234..b5229f72a 100644 --- a/cmd/disk-cache-backend.go +++ b/cmd/disk-cache-backend.go @@ -460,7 +460,7 @@ func (c *diskCache) saveMetadata(ctx context.Context, bucket, object string, met if m.Meta == nil { m.Meta = make(map[string]string) } - if etag, ok := meta["etag"]; !ok { + if etag, ok := meta["etag"]; ok { m.Meta["etag"] = etag } } diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index e677b37e6..4ee9f8165 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -297,7 +297,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string oi, _, _, err := dcache.statRange(ctx, bucket, object, rs) // avoid cache overwrite if another background routine filled cache if err != nil || oi.ETag != bReader.ObjInfo.ETag { - dcache.Put(ctx, bucket, object, bReader, bReader.ObjInfo.Size, rs, ObjectOptions{UserDefined: getMetadata(bReader.ObjInfo)}, true) + dcache.Put(ctx, bucket, object, bReader, bReader.ObjInfo.Size, rs, ObjectOptions{UserDefined: getMetadata(bReader.ObjInfo)}, false) } }() return bkReader, bkErr @@ -647,7 +647,7 @@ func (c *cacheObjects) PutObject(ctx context.Context, bucket, object string, r * oi, _, err := dcache.Stat(ctx, bucket, object) // avoid cache overwrite if another background routine filled cache if err != nil || oi.ETag != bReader.ObjInfo.ETag { - dcache.Put(ctx, bucket, object, bReader, bReader.ObjInfo.Size, nil, ObjectOptions{UserDefined: getMetadata(bReader.ObjInfo)}, true) + dcache.Put(ctx, bucket, object, bReader, bReader.ObjInfo.Size, nil, ObjectOptions{UserDefined: getMetadata(bReader.ObjInfo)}, false) } }() }