From df9894e275bc2e533208921d0f3992d4f94af3a7 Mon Sep 17 00:00:00 2001 From: Kaloyan Raev Date: Tue, 27 Oct 2020 08:04:48 +0200 Subject: [PATCH] avoid caching http ranges in background goroutine (#10724) --- cmd/disk-cache.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index a46973986..3696d8838 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -305,12 +305,10 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string return bkReader, bkErr } - if rs != nil { + if rs != nil && !dcache.enableRange { go func() { // if range caching is disabled, download entire object. - if !dcache.enableRange { - rs = nil - } + rs = nil // fill cache in the background for range GET requests bReader, bErr := c.InnerGetObjectNInfoFn(GlobalContext, bucket, object, rs, h, lockType, opts) if bErr != nil { @@ -337,7 +335,7 @@ func (c *cacheObjects) GetObjectNInfo(ctx context.Context, bucket, object string go func() { putErr := dcache.Put(ctx, bucket, object, io.LimitReader(pipeReader, bkReader.ObjInfo.Size), - bkReader.ObjInfo.Size, nil, ObjectOptions{ + bkReader.ObjInfo.Size, rs, ObjectOptions{ UserDefined: userDefined, }, false) // close the write end of the pipe, so the error gets