]> source.dussan.org Git - gitea.git/commitdiff
[Fix] Release attachment should use DownloadURL() not Name (#9529)
author6543 <6543@obermui.de>
Sat, 28 Dec 2019 23:33:13 +0000 (00:33 +0100)
committerzeripath <art27@cantab.net>
Sat, 28 Dec 2019 23:33:13 +0000 (23:33 +0000)
* 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

routers/repo/repo.go
templates/repo/issue/view_content/attachments.tmpl
templates/repo/release/list.tmpl

index 969f96bfba3515a73fa1171a08e9d4023bd29994..d44812729fe4ef6518e3f80c642356d53b4750d8 100644 (file)
@@ -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
                }
        }
index e2d7d1b9de67923f82b287c8c99d51df57128934..a97f5d85da42984245d5ed9394b1b73b5641fd0d 100644 (file)
@@ -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}}
\ No newline at end of file
+{{end}}
index 777d3a2b050cf98b63351e039cd348a40f524fda..90a45b9b6762027bd4274c7508f797c7938630aa 100644 (file)
                                                                        </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}}