diff --git a/modules/git/attribute/batch.go b/modules/git/attribute/batch.go index 60db21d0c72..27f9111301a 100644 --- a/modules/git/attribute/batch.go +++ b/modules/git/attribute/batch.go @@ -13,6 +13,7 @@ import ( "gitea.dev/modules/git" "gitea.dev/modules/git/gitcmd" "gitea.dev/modules/log" + "gitea.dev/modules/setting" ) // BatchChecker provides a reader for check-attribute content that can be long running @@ -120,12 +121,17 @@ func (c *BatchChecker) CheckPath(path string) (rs *Attributes, err error) { return fmt.Errorf("CheckPath timeout: %s", debugMsg) } + timeout := time.NewTimer(5 * time.Second) + defer timeout.Stop() + rs = NewAttributes() for i := 0; i < c.attributesNum; i++ { select { - case <-time.After(5 * time.Second): + case <-timeout.C: // there is no "hang" problem now. This code is just used to catch other potential problems. - return nil, reportTimeout() + err = reportTimeout() + setting.PanicInDevOrTesting("Unexpected timeout, need to investigate: %v", err) + return nil, err case attr, ok := <-c.stdOut.ReadAttribute(): if !ok { return nil, c.ctx.Err()