From 03172b89e28d686b2454eacc7279d6fbaea08a98 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Wed, 24 Feb 2021 02:59:49 -0800 Subject: [PATCH] Ensure cache has finished deserializing (#11620) Make sure that response has been fully deserialized before returning. --- cmd/storage-rest-client.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index 951153985..8d890538a 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -186,14 +186,11 @@ func (client *storageRESTClient) CrawlAndGetDataUsage(ctx context.Context, cache var newCache dataUsageCache pr, pw = io.Pipe() go func() { - pr.CloseWithError(newCache.deserialize(pr)) + pw.CloseWithError(waitForHTTPStream(respBody, pw)) }() - err = waitForHTTPStream(respBody, pw) - pw.CloseWithError(err) - if err != nil { - return cache, err - } - return newCache, nil + err = newCache.deserialize(pr) + pr.CloseWithError(err) + return newCache, err } func (client *storageRESTClient) GetDiskID() (string, error) {