You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/modules
zeripath 06f968d662
Fix hard-coded timeout and error panic in API archive download endpoint (#20925) (#21051)
Backport #20925

This commit updates the `GET /api/v1/repos/{owner}/{repo}/archive/{archive}`
endpoint which prior to this PR had a couple of issues.

1. The endpoint had a hard-coded 20s timeout for the archiver to complete after
   which a 500 (Internal Server Error) was returned to client. For a scripted
   API client there was no clear way of telling that the operation timed out and
   that it should retry.

2. Whenever the timeout _did occur_, the code used to panic. This was caused by
   the API endpoint "delegating" to the same call path as the web, which uses a
   slightly different way of reporting errors (HTML rather than JSON for
   example).

   More specifically, `api/v1/repo/file.go#GetArchive` just called through to
   `web/repo/repo.go#Download`, which expects the `Context` to have a `Render`
   field set, but which is `nil` for API calls. Hence, a `nil` pointer error.

The code addresses (1) by dropping the hard-coded timeout. Instead, any
timeout/cancelation on the incoming `Context` is used.

The code addresses (2) by updating the API endpoint to use a separate call path
for the API-triggered archive download. This avoids producing HTML-errors on
errors (it now produces JSON errors).

Signed-off-by: Peter Gardfjäll <peter.gardfjall.work@gmail.com>

Signed-off-by: Peter Gardfjäll <peter.gardfjall.work@gmail.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Peter Gardfjäll <peter.gardfjall.work@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
3 years ago
..
activitypub
analyze Simplify `IsVendor` (#19626) 3 years ago
appstate
auth Remove legacy `+build:` constraint (#19582) 3 years ago
avatar Remove legacy `+build:` constraint (#19582) 3 years ago
base Prettify number of issues (#17760) 3 years ago
cache Update go-chi/cache to utilize Ping() (#19719) 3 years ago
charset Detect truncated utf-8 characters at the end of content as still representing utf-8 (#19773) 3 years ago
container
context Fix download archiver of a commit (#20962) (#20971) 3 years ago
convert Fix 500 on time in timeline API (#21052) (#21057) 3 years ago
csv Allow render HTML with css/js external links (#19017) 3 years ago
doctor Fix git.Init for doctor sub-command (#20782) (#20783) 3 years ago
emoji
eventsource Stop spurious APIFormat stopwatches logs (#20008) 3 years ago
generate
git Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (#20902) (#21058) 3 years ago
gitgraph Move some code into models/git (#19879) 3 years ago
graceful Ensure that graceful start-up is informed of unused SSH listener (#20877) 3 years ago
hcaptcha
highlight Adjust line detection in highlight.go (#20612) 3 years ago
hostmatcher fix merge (#20819) 3 years ago
httpcache Add Cache-Control header to html and api responses, add no-transform (#20432) (#20459) 3 years ago
httplib
indexer Fix `dump-repo` git init, fix wrong error type for NullDownloader (#20182) (#20186) 3 years ago
json
lfs Move some code into models/git (#19879) 3 years ago
log Disable doctor logging on panic (#20847) (#20898) 3 years ago
markup Fix NPE when using non-numeric (#20277) (#20278) 3 years ago
metrics
migration Add more checks in migration code (#21011) (#21050) 3 years ago
nosql fix broken insecureskipverify handling in rediss connection uris (#20967) (#21053) 3 years ago
notification Move issues related files into models/issues (#19931) 3 years ago
options Remove legacy `+build:` constraint (#19582) 3 years ago
packages Add migrate repo archiver and packages storage support on command line (#20757) (#20806) 3 years ago
paginator
password
pprof
private
process Set Setpgid on child git processes (#19865) 3 years ago
proxy
public Remove legacy `+build:` constraint (#19582) 3 years ago
queue
recaptcha
references Custom regexp external issues (#17624) 3 years ago
regexplru Custom regexp external issues (#17624) 3 years ago
repository Executable check always returns true for windows (#20637) (#20835) 3 years ago
secret
session
setting Enable contenthash in filename for dynamic assets (#20813) (#20932) 3 years ago
ssh Ensure that graceful start-up is informed of unused SSH listener (#20877) 3 years ago
storage
structs Dismiss prior pull reviews if done via web in review dismiss (#20197) (#20407) 3 years ago
svg Remove legacy `+build:` constraint (#19582) 3 years ago
sync
templates Enable contenthash in filename for dynamic assets (#20813) (#20932) 3 years ago
test Move access and repo permission to models/perm/access (#19350) 3 years ago
timeutil Fix hard-coded timeout and error panic in API archive download endpoint (#20925) (#21051) 3 years ago
translation
typesniffer Rework raw file http header logic (#20484) (#20542) 3 years ago
updatechecker
upload
uri
user
util Fix SecToTime edge-cases (#20610) (#20611) 3 years ago
validation Add more checks in migration code (#21011) (#21050) 3 years ago
web Unify repo settings & show better error (#19828) 3 years ago