diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/attachment.go | 11 | ||||
-rw-r--r-- | routers/web/repo/release.go | 6 | ||||
-rw-r--r-- | routers/web/repo/repo.go | 2 |
3 files changed, 15 insertions, 4 deletions
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index c6d8828fac..9fb9cb00bf 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -86,9 +86,9 @@ func DeleteAttachment(ctx *context.Context) { }) } -// GetAttachment serve attachments -func GetAttachment(ctx *context.Context) { - attach, err := repo_model.GetAttachmentByUUID(ctx, ctx.Params(":uuid")) +// GetAttachment serve attachments with the given UUID +func ServeAttachment(ctx *context.Context, uuid string) { + attach, err := repo_model.GetAttachmentByUUID(ctx, uuid) if err != nil { if repo_model.IsErrAttachmentNotExist(err) { ctx.Error(http.StatusNotFound) @@ -153,3 +153,8 @@ func GetAttachment(ctx *context.Context) { return } } + +// GetAttachment serve attachments +func GetAttachment(ctx *context.Context) { + ServeAttachment(ctx, ctx.Params(":uuid")) +} diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 14ef1372c0..e8caa2cbb7 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -142,6 +142,10 @@ func releasesOrTags(ctx *context.Context, isTagList bool) { return } + for _, release := range releases { + release.Repo = ctx.Repo.Repository + } + if err = repo_model.GetReleaseAttachments(ctx, releases...); err != nil { ctx.ServerError("GetReleaseAttachments", err) return @@ -248,6 +252,8 @@ func SingleRelease(ctx *context.Context) { ctx.Data["Title"] = release.Title } + release.Repo = ctx.Repo.Repository + err = repo_model.GetReleaseAttachments(ctx, release) if err != nil { ctx.ServerError("GetReleaseAttachments", err) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 9b80e85324..5a97c5190c 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -373,7 +373,7 @@ func RedirectDownload(ctx *context.Context) { return } if att != nil { - ctx.Redirect(att.DownloadURL()) + ServeAttachment(ctx, att.UUID) return } } |