Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands lagging for ~8 seconds due to version-check #2498

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,41 +276,41 @@ func beginDetectNewVersion() chan struct{} {
cachedVersion, err := ValidateCachedVersion(filePath) // same as the remote version
if err == nil {
PrintOlderVersion(*cachedVersion, *localVersion)
return
}
} else {
// step 2: initialize pipeline
options := createClientOptions(nil)

// step 2: initialize pipeline
options := createClientOptions(nil)

// step 3: start download
blobClient, err := blob.NewClientWithNoCredential(versionMetadataUrl, &blob.ClientOptions{ClientOptions: options})
if err != nil {
return
}
// step 3: start download
blobClient, err := blob.NewClientWithNoCredential(versionMetadataUrl, &blob.ClientOptions{ClientOptions: options})
if err != nil {
return
}

downloadBlobResp, err := blobClient.DownloadStream(context.TODO(), nil)
if err != nil {
return
}
downloadBlobResp, err := blobClient.DownloadStream(context.TODO(), nil)
if err != nil {
return
}

// step 4: read newest version str
data := make([]byte, *downloadBlobResp.ContentLength)
_, err = downloadBlobResp.Body.Read(data)
if err != nil && err != io.EOF {
return
}
// step 4: read newest version str
data := make([]byte, *downloadBlobResp.ContentLength)
_, err = downloadBlobResp.Body.Read(data)
defer downloadBlobResp.Body.Close()
if err != nil && err != io.EOF {
return
}

remoteVersion, err := NewVersion(string(data))
if err != nil {
return
}
remoteVersion, err := NewVersion(string(data))
if err != nil {
return
}

PrintOlderVersion(*remoteVersion, *localVersion)
PrintOlderVersion(*remoteVersion, *localVersion)

// step 5: persist remote version in local
err = localVersion.CacheRemoteVersion(*remoteVersion, filePath)
if err != nil {
return
// step 5: persist remote version in local
err = localVersion.CacheRemoteVersion(*remoteVersion, filePath)
if err != nil {
return
}
}

// let caller know we have finished, if they want to know
Expand Down
Loading