File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "os"
1212 "path"
1313
14+ "code.gitea.io/gitea/modules/log"
1415 "code.gitea.io/gitea/modules/setting"
1516 "code.gitea.io/gitea/modules/util"
1617 api "code.gitea.io/sdk/gitea"
@@ -75,6 +76,16 @@ func (a *Attachment) Size() (int64, error) {
7576 return fi .Size (), nil
7677}
7778
79+ // MustSize returns the result of a.Size() by ignoring errors
80+ func (a * Attachment ) MustSize () int64 {
81+ size , err := a .Size ()
82+ if err != nil {
83+ log .Error (4 , "size: %v" , err )
84+ return 0
85+ }
86+ return size
87+ }
88+
7889// DownloadURL returns the download url of the attached file
7990func (a * Attachment ) DownloadURL () string {
8091 return fmt .Sprintf ("%sattachments/%s" , setting .AppURL , a .UUID )
Original file line number Diff line number Diff line change 6868 <ul class="list">
6969 {{if $.Repository.UnitEnabled $.UnitTypeCode}}
7070 <li>
71- <a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (ZIP)</a>
71+ <a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><strong>< i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (ZIP)</strong> </a>
7272 </li>
7373 <li>
74- <a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (TAR.GZ)</a>
74+ <a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><strong>< i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (TAR.GZ)</strong> </a>
7575 </li>
7676 {{end}}
7777 {{if .Attachments}}
7878 {{range .Attachments}}
7979 <li>
8080 <a target="_blank" rel="noopener" href="{{AppSubUrl}}/attachments/{{.UUID}}">
81- <span class="ui image octicon octicon-desktop-download" title='{{.Name}}'></span> {{.Name}}
81+ <strong><span class="ui image octicon octicon-package" title='{{.Name}}'></span> {{.Name}}</strong>
82+ <span class="ui text grey right">{{.MustSize | FileSize}}</span>
8283 </a>
8384 </li>
8485 {{end}}
You can’t perform that action at this time.
0 commit comments