Skip to content

Commit

Permalink
[Fix] Release attachment should use DownloadURL() not Name (#9529)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
6543 authored and zeripath committed Dec 28, 2019
1 parent 599c0ee commit 261c3a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion routers/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func RedirectDownload(ctx *context.Context) {
return
}
if att != nil {
ctx.Redirect(setting.AppSubURL + "/attachments/" + att.UUID)
ctx.Redirect(att.DownloadURL())
return
}
}
Expand Down
6 changes: 3 additions & 3 deletions templates/repo/issue/view_content/attachments.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{range .Attachments}}
<a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}">
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
{{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}}
<span class="ui image octicon octicon-desktop-download" title='{{$.ctx.i18n.Tr "repo.issues.attachment.download" .Name}}'></span>
{{end}}
</a>
{{end}}
{{end}}
8 changes: 4 additions & 4 deletions templates/repo/release/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@
</li>
{{end}}
{{if .Attachments}}
{{range $attachment := .Attachments}}
{{range .Attachments}}
<li>
<a target="_blank" rel="noopener noreferrer" href="{{$.RepoLink}}/releases/download/{{$release.TagName | PathEscape}}/{{$attachment.Name | PathEscape}}">
<strong><span class="ui image octicon octicon-package" title='{{$attachment.Name}}'></span> {{$attachment.Name}}</strong>
<span class="ui text grey right">{{$attachment.Size | FileSize}}</span>
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
<strong><span class="ui image octicon octicon-package" title='{{.Name}}'></span> {{.Name}}</strong>
<span class="ui text grey right">{{.Size | FileSize}}</span>
</a>
</li>
{{end}}
Expand Down

0 comments on commit 261c3a5

Please sign in to comment.