Ensure cache has finished deserializing (#11620)

Make sure that response has been fully deserialized before returning.
This commit is contained in:
Klaus Post 2021-02-24 02:59:49 -08:00 committed by GitHub
parent b517c791e9
commit 03172b89e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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