From 43fc430c078d61cf7ab428c3cf0e07eeebd0445e Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Mon, 19 Mar 2018 17:06:00 +0100 Subject: [PATCH] Improve release page UI (#3693) * Improve release page ui by adding size Signed-off-by: Jonas Franz * Add documentation to a.MustSize() Signed-off-by: Jonas Franz --- models/attachment.go | 11 +++++++++++ templates/repo/release/list.tmpl | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index ffe2eea80c85a..47c76990bc2af 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) diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index dd220b6a8483e..73e4a868211f2 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -68,17 +68,18 @@