forked from gitea/gitea
Backport #20346 Although `WalkGitLog` tries to test for `context.DeadlineExceededErr` there is a small chance that the error will propagate to the reader before it is recognised. This will cause the error to propagate up to `renderDirectoryFiles` and cause a http status 500. Here we check that the error passed is a `DeadlineExceededErr` via error.Is Fix #20329 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
f4e219f668
commit
780b198997
|
@ -8,6 +8,7 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -62,9 +63,10 @@ func LogNameStatusRepo(ctx context.Context, repository, head, treepath string, p
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = stdoutWriter.CloseWithError(ConcatenateError(err, (&stderr).String()))
|
_ = stdoutWriter.CloseWithError(ConcatenateError(err, (&stderr).String()))
|
||||||
} else {
|
return
|
||||||
_ = stdoutWriter.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ = stdoutWriter.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// For simplicities sake we'll us a buffered reader to read from the cat-file --batch
|
// For simplicities sake we'll us a buffered reader to read from the cat-file --batch
|
||||||
|
@ -354,7 +356,7 @@ heaploop:
|
||||||
}
|
}
|
||||||
current, err := g.Next(treepath, path2idx, changed, maxpathlen)
|
current, err := g.Next(treepath, path2idx, changed, maxpathlen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == context.DeadlineExceeded {
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
break heaploop
|
break heaploop
|
||||||
}
|
}
|
||||||
g.Close()
|
g.Close()
|
||||||
|
|
Loading…
Reference in New Issue