From 57a3a090f12b8def1012a96f082ef4e332cd4cbb Mon Sep 17 00:00:00 2001 From: Jo Date: Sun, 16 Apr 2023 18:23:10 +0200 Subject: [PATCH] fix(vcs): improve timeout handling for vcs upgrade check (#2120) remove timeout from full operation and increase timeout for single checking --- pkg/upgrade/sources.go | 5 +---- pkg/vcs/vcs.go | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/upgrade/sources.go b/pkg/upgrade/sources.go index 86c3fec8..e8b31d4e 100644 --- a/pkg/upgrade/sources.go +++ b/pkg/upgrade/sources.go @@ -2,7 +2,6 @@ package upgrade import ( "context" - "time" "github.com/leonelquinteros/gotext" @@ -22,10 +21,8 @@ func UpDevel( toRemove := make([]string, 0) toUpgrade := UpSlice{Up: make([]Upgrade, 0), Repos: []string{"devel"}} - ctxTimeout, cancel := context.WithTimeout(ctx, 20*time.Second) - defer cancel() for pkgName, pkg := range remote { - if localCache.ToUpgrade(ctxTimeout, pkgName) { + if localCache.ToUpgrade(ctx, pkgName) { if _, ok := aurdata[pkgName]; !ok { log.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName) continue diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index ca3442f8..d45a6c93 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -19,6 +19,8 @@ import ( "github.com/Jguer/yay/v12/pkg/text" ) +const defaultTimeout = 15 * time.Second + type Store interface { // ToUpgrade returns true if the package needs to be updated. ToUpgrade(ctx context.Context, pkgName string) bool @@ -82,7 +84,7 @@ func (v *InfoStore) getCommit(ctx context.Context, url, branch string, protocols if len(protocols) > 0 { protocol := protocols[len(protocols)-1] - ctxTimeout, cancel := context.WithTimeout(ctx, 10*time.Second) + ctxTimeout, cancel := context.WithTimeout(ctx, defaultTimeout) defer cancel() cmd := v.CmdBuilder.BuildGitCmd(ctxTimeout, "", "ls-remote", protocol+"://"+url, branch)