Skip to content

Commit 261c3a5

Browse files
6543zeripath
authored andcommitted
[Fix] Release attachment should use DownloadURL() not Name (#9529)
* Handle if two or more attachments have the same name * previously only the first could be downloaded - now each is downloadable * dos also take care of #6506 (fix was: #6512) * use func DownloadURL() at issue attatchments too
1 parent 599c0ee commit 261c3a5

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

routers/repo/repo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func RedirectDownload(ctx *context.Context) {
426426
return
427427
}
428428
if att != nil {
429-
ctx.Redirect(setting.AppSubURL + "/attachments/" + att.UUID)
429+
ctx.Redirect(att.DownloadURL())
430430
return
431431
}
432432
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{{range .Attachments}}
2-
<a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}">
2+
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
33
{{if FilenameIsImage .Name}}
4-
<img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
4+
<img class="ui image" src="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
55
{{else}}
66
<span class="ui image octicon octicon-desktop-download" title='{{$.ctx.i18n.Tr "repo.issues.attachment.download" .Name}}'></span>
77
{{end}}
88
</a>
9-
{{end}}
9+
{{end}}

templates/repo/release/list.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282
</li>
8383
{{end}}
8484
{{if .Attachments}}
85-
{{range $attachment := .Attachments}}
85+
{{range .Attachments}}
8686
<li>
87-
<a target="_blank" rel="noopener noreferrer" href="{{$.RepoLink}}/releases/download/{{$release.TagName | PathEscape}}/{{$attachment.Name | PathEscape}}">
88-
<strong><span class="ui image octicon octicon-package" title='{{$attachment.Name}}'></span> {{$attachment.Name}}</strong>
89-
<span class="ui text grey right">{{$attachment.Size | FileSize}}</span>
87+
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
88+
<strong><span class="ui image octicon octicon-package" title='{{.Name}}'></span> {{.Name}}</strong>
89+
<span class="ui text grey right">{{.Size | FileSize}}</span>
9090
</a>
9191
</li>
9292
{{end}}

0 commit comments

Comments
 (0)