diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-11 15:16:23 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-11 09:16:23 +0200 |
commit | 956354885a60abe82ac608e764fcb56d4016339e (patch) | |
tree | 121f94322618f6f94c8b6fcb13123a9083e9899f /models/attachment.go | |
parent | 03ec35ed79e38b907de8812e3f7cccc422cb5937 (diff) | |
download | gitea-956354885a60abe82ac608e764fcb56d4016339e.tar.gz gitea-956354885a60abe82ac608e764fcb56d4016339e.zip |
simple usage of x (#3144)
Diffstat (limited to 'models/attachment.go')
-rw-r--r-- | models/attachment.go | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/models/attachment.go b/models/attachment.go index cadb23a574..e7e0dbf5c2 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -31,11 +31,8 @@ type Attachment struct { // IncreaseDownloadCount is update download count + 1 func (a *Attachment) IncreaseDownloadCount() error { - sess := x.NewSession() - defer sess.Close() - // Update download count. - if _, err := sess.Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil { + if _, err := x.Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil { return fmt.Errorf("increase attachment count: %v", err) } |