]> source.dussan.org Git - gitea.git/commitdiff
Don't show context cancelled errors in attribute reader (#19006)
authorzeripath <art27@cantab.net>
Tue, 8 Mar 2022 08:30:14 +0000 (08:30 +0000)
committerGitHub <noreply@github.com>
Tue, 8 Mar 2022 08:30:14 +0000 (08:30 +0000)
Fix #18997

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
modules/git/repo_attribute.go

index 772ee6ad12b46cab25b1498e54d9dca98392e767..ce24b0a7a341633c4a741c54206a114bba44541e 100644 (file)
@@ -205,7 +205,9 @@ func (c *CheckAttributeReader) Run() error {
                        return nil
                },
        })
-       if err != nil && c.ctx.Err() != nil && err.Error() != "signal: killed" {
+       if err != nil && //                      If there is an error we need to return but:
+               c.ctx.Err() != err && //             1. Ignore the context error if the context is cancelled or exceeds the deadline (RunWithContext could return c.ctx.Err() which is Canceled or DeadlineExceeded)
+               err.Error() != "signal: killed" { // 2. We should not pass up errors due to the program being killed
                return fmt.Errorf("failed to run attr-check. Error: %w\nStderr: %s", err, stdErr.String())
        }
        return nil