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 var newCache dataUsageCache
pr, pw = io.Pipe() pr, pw = io.Pipe()
go func() { go func() {
pr.CloseWithError(newCache.deserialize(pr)) pw.CloseWithError(waitForHTTPStream(respBody, pw))
}() }()
err = waitForHTTPStream(respBody, pw) err = newCache.deserialize(pr)
pw.CloseWithError(err) pr.CloseWithError(err)
if err != nil { return newCache, err
return cache, err
}
return newCache, nil
} }
func (client *storageRESTClient) GetDiskID() (string, error) { func (client *storageRESTClient) GetDiskID() (string, error) {