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) {