[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
This commit is contained in:
parent
599c0ee75f
commit
261c3a56a2
3 changed files with 8 additions and 8 deletions
|
@ -426,7 +426,7 @@ func RedirectDownload(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if att != nil {
|
if att != nil {
|
||||||
ctx.Redirect(setting.AppSubURL + "/attachments/" + att.UUID)
|
ctx.Redirect(att.DownloadURL())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{{range .Attachments}}
|
{{range .Attachments}}
|
||||||
<a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}">
|
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
|
||||||
{{if FilenameIsImage .Name}}
|
{{if FilenameIsImage .Name}}
|
||||||
<img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
<img class="ui image" src="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="ui image octicon octicon-desktop-download" title='{{$.ctx.i18n.Tr "repo.issues.attachment.download" .Name}}'></span>
|
<span class="ui image octicon octicon-desktop-download" title='{{$.ctx.i18n.Tr "repo.issues.attachment.download" .Name}}'></span>
|
||||||
{{end}}
|
{{end}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -82,11 +82,11 @@
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Attachments}}
|
{{if .Attachments}}
|
||||||
{{range $attachment := .Attachments}}
|
{{range .Attachments}}
|
||||||
<li>
|
<li>
|
||||||
<a target="_blank" rel="noopener noreferrer" href="{{$.RepoLink}}/releases/download/{{$release.TagName | PathEscape}}/{{$attachment.Name | PathEscape}}">
|
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
|
||||||
<strong><span class="ui image octicon octicon-package" title='{{$attachment.Name}}'></span> {{$attachment.Name}}</strong>
|
<strong><span class="ui image octicon octicon-package" title='{{.Name}}'></span> {{.Name}}</strong>
|
||||||
<span class="ui text grey right">{{$attachment.Size | FileSize}}</span>
|
<span class="ui text grey right">{{.Size | FileSize}}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Reference in a new issue