aboutsummaryrefslogtreecommitdiffstats
path: root/models/attachment.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-06-18 01:50:11 +0800
committerGitHub <noreply@github.com>2020-06-17 20:50:11 +0300
commit1645d4a5d8def3cc5451e068aa0a321e028a889b (patch)
tree99e1f29ec2dbb568cfee090ea4a2e49dfca02280 /models/attachment.go
parent61cd0ce86601a0bffb625ae27a7b76ee8a15cb36 (diff)
downloadgitea-1645d4a5d8def3cc5451e068aa0a321e028a889b.tar.gz
gitea-1645d4a5d8def3cc5451e068aa0a321e028a889b.zip
Use ID or Where to instead directly use Get when load object from database (#11925)
* Use ID or Where to instead directly use Get when load object from database * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/attachment.go')
-rw-r--r--models/attachment.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/models/attachment.go b/models/attachment.go
index 7e59c7eef4..a5f264b32b 100644
--- a/models/attachment.go
+++ b/models/attachment.go
@@ -136,9 +136,8 @@ func GetAttachmentByID(id int64) (*Attachment, error) {
}
func getAttachmentByID(e Engine, id int64) (*Attachment, error) {
- attach := &Attachment{ID: id}
-
- if has, err := e.Get(attach); err != nil {
+ attach := &Attachment{}
+ if has, err := e.ID(id).Get(attach); err != nil {
return nil, err
} else if !has {
return nil, ErrAttachmentNotExist{ID: id, UUID: ""}
@@ -147,8 +146,8 @@ func getAttachmentByID(e Engine, id int64) (*Attachment, error) {
}
func getAttachmentByUUID(e Engine, uuid string) (*Attachment, error) {
- attach := &Attachment{UUID: uuid}
- has, err := e.Get(attach)
+ attach := &Attachment{}
+ has, err := e.Where("uuid=?", uuid).Get(attach)
if err != nil {
return nil, err
} else if !has {