summaryrefslogtreecommitdiffstats
path: root/models/ssh_key.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-09-25 12:59:27 +0800
committerGitHub <noreply@github.com>2017-09-25 12:59:27 +0800
commitdd55534b82ca9527b68fddf0f63ebb13c105c466 (patch)
tree5e1398ac3d07da8b7e4cb4fdd52695cea19b62b7 /models/ssh_key.go
parent6b6f16cfae5636deb88003fc5b0290450afb4137 (diff)
downloadgitea-dd55534b82ca9527b68fddf0f63ebb13c105c466.tar.gz
gitea-dd55534b82ca9527b68fddf0f63ebb13c105c466.zip
Reduce usage of allcols on update (#2596)
* reduce usage of allcols on update * fix bug and tests
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r--models/ssh_key.go10
1 files changed, 1 insertions, 9 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 539c60e696..c8f65ef0d1 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -477,15 +477,8 @@ func ListPublicKeys(uid int64) ([]*PublicKey, error) {
Find(&keys)
}
-// UpdatePublicKey updates given public key.
-func UpdatePublicKey(key *PublicKey) error {
- _, err := x.Id(key.ID).AllCols().Update(key)
- return err
-}
-
// UpdatePublicKeyUpdated updates public key use time.
func UpdatePublicKeyUpdated(id int64) error {
- now := time.Now()
// Check if key exists before update as affected rows count is unreliable
// and will return 0 affected rows if two updates are made at the same time
if cnt, err := x.ID(id).Count(&PublicKey{}); err != nil {
@@ -495,8 +488,7 @@ func UpdatePublicKeyUpdated(id int64) error {
}
_, err := x.ID(id).Cols("updated_unix").Update(&PublicKey{
- Updated: now,
- UpdatedUnix: now.Unix(),
+ UpdatedUnix: time.Now().Unix(),
})
if err != nil {
return err