fix: correct repo/attatchment absolute url and release layout (#39178)

This commit is contained in:
wxiaoguang
2026-08-31 23:31:17 +00:00
committed by GitHub
parent fc9800b383
commit 4875bb3b2b
21 changed files with 72 additions and 80 deletions
+5 -3
View File
@@ -12,6 +12,7 @@ import (
"path"
"gitea.dev/models/db"
"gitea.dev/modules/httplib"
"gitea.dev/modules/log"
"gitea.dev/modules/setting"
"gitea.dev/modules/storage"
@@ -62,12 +63,13 @@ func (a *Attachment) RelativePath() string {
}
// DownloadURL returns the download url of the attached file
func (a *Attachment) DownloadURL() string {
func (a *Attachment) DownloadURL(optCtx ...context.Context) string {
// mail template doesn't have context, so we need to use a default one
ctx := util.OptionalArg(optCtx, context.TODO())
if a.CustomDownloadURL != "" {
return a.CustomDownloadURL
}
return setting.AppURL + "attachments/" + url.PathEscape(a.UUID)
return httplib.MakeAbsoluteURL(ctx, setting.AppSubURL+"/attachments/"+url.PathEscape(a.UUID))
}
// ErrAttachmentNotExist represents a "AttachmentNotExist" kind of error.