|
|
|
@@ -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) |
|
|
|
|