summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2018-03-19 17:06:00 +0100
committerLauris BH <lauris@nix.lv>2018-03-19 18:06:00 +0200
commit43fc430c078d61cf7ab428c3cf0e07eeebd0445e (patch)
tree6fba9264ffb8a58420109c083fcb739624d76d62 /models
parent47422c2635343604d713d91a96308ce1717bc6cf (diff)
downloadgitea-43fc430c078d61cf7ab428c3cf0e07eeebd0445e.tar.gz
gitea-43fc430c078d61cf7ab428c3cf0e07eeebd0445e.zip
Improve release page UI (#3693)
* Improve release page ui by adding size Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add documentation to a.MustSize() Signed-off-by: Jonas Franz <info@jonasfranz.software>
Diffstat (limited to 'models')
-rw-r--r--models/attachment.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/models/attachment.go b/models/attachment.go
index ffe2eea80c..47c76990bc 100644
--- a/models/attachment.go
+++ b/models/attachment.go
@@ -11,6 +11,7 @@ import (
"os"
"path"
+ "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
api "code.gitea.io/sdk/gitea"
@@ -75,6 +76,16 @@ func (a *Attachment) Size() (int64, error) {
return fi.Size(), nil
}
+// MustSize returns the result of a.Size() by ignoring errors
+func (a *Attachment) MustSize() int64 {
+ size, err := a.Size()
+ if err != nil {
+ log.Error(4, "size: %v", err)
+ return 0
+ }
+ return size
+}
+
// DownloadURL returns the download url of the attached file
func (a *Attachment) DownloadURL() string {
return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID)