Merge pull request #14997 from spowelljr/refactorCheck

Fix update check logic
pull/15037/head
Steven Powell 2022-09-29 10:04:01 -07:00 committed by GitHub
commit ac729579b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -148,11 +148,8 @@ func runStart(cmd *cobra.Command, args []string) {
displayVersion(version.GetVersion())
go download.CleanUpOlderPreloads()
// No need to do the update check if no one is going to see it
if !viper.GetBool(interactive) || !viper.GetBool(dryRun) {
// Avoid blocking execution on optional HTTP fetches
go notify.MaybePrintUpdateTextFromGithub()
}
// Avoid blocking execution on optional HTTP fetches
go notify.MaybePrintUpdateTextFromGithub()
displayEnviron(os.Environ())
if viper.GetBool(force) {

View File

@ -119,6 +119,9 @@ func shouldCheckURLVersion(filePath string) bool {
if !viper.GetBool(config.WantUpdateNotification) {
return false
}
if !viper.GetBool("interactive") {
return false
}
lastUpdateTime := timeFromFileIfExists(filePath)
return time.Since(lastUpdateTime).Hours() >= viper.GetFloat64(config.ReminderWaitPeriodInHours)
}

View File

@ -36,6 +36,7 @@ import (
)
func TestShouldCheckURLVersion(t *testing.T) {
viper.Set("interactive", true)
tempDir := tests.MakeTempDir(t)
lastUpdateCheckFilePath := filepath.Join(tempDir, "last_update_check")
@ -74,6 +75,7 @@ func TestShouldCheckURLVersion(t *testing.T) {
}
func TestShouldCheckURLBetaVersion(t *testing.T) {
viper.Set("interactive", true)
tempDir := tests.MakeTempDir(t)
lastUpdateCheckFilePath := filepath.Join(tempDir, "last_update_check")