File tree 1 file changed +17
-4
lines changed 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -378,10 +378,6 @@ func RedirectDownload(ctx *context.Context) {
378
378
curRepo := ctx .Repo .Repository
379
379
releases , err := repo_model .GetReleasesByRepoIDAndNames (ctx , curRepo .ID , tagNames )
380
380
if err != nil {
381
- if repo_model .IsErrAttachmentNotExist (err ) {
382
- ctx .Error (http .StatusNotFound )
383
- return
384
- }
385
381
ctx .ServerError ("RedirectDownload" , err )
386
382
return
387
383
}
@@ -396,6 +392,23 @@ func RedirectDownload(ctx *context.Context) {
396
392
ServeAttachment (ctx , att .UUID )
397
393
return
398
394
}
395
+ } else if len (releases ) == 0 && vTag == "latest" {
396
+ // GitHub supports the alias "latest" for the latest release
397
+ // We only fetch the latest release if the tag is "latest" and no release with the tag "latest" exists
398
+ release , err := repo_model .GetLatestReleaseByRepoID (ctx .Repo .Repository .ID )
399
+ if err != nil {
400
+ ctx .Error (http .StatusNotFound )
401
+ return
402
+ }
403
+ att , err := repo_model .GetAttachmentByReleaseIDFileName (ctx , release .ID , fileName )
404
+ if err != nil {
405
+ ctx .Error (http .StatusNotFound )
406
+ return
407
+ }
408
+ if att != nil {
409
+ ServeAttachment (ctx , att .UUID )
410
+ return
411
+ }
399
412
}
400
413
ctx .Error (http .StatusNotFound )
401
414
}
You can’t perform that action at this time.
0 commit comments