summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-04-07 17:40:38 -0700
committerGitHub <noreply@github.com>2017-04-07 17:40:38 -0700
commit5c0bee9b20f50a26c7ac3fa90d1db2b8329d358b (patch)
tree365da2ff66c28f5f5fb179fa9387b5257c7a7ac2 /models
parentd9db1882745baf44e16375eb1dc4733bf2989848 (diff)
downloadgitea-5c0bee9b20f50a26c7ac3fa90d1db2b8329d358b.tar.gz
gitea-5c0bee9b20f50a26c7ac3fa90d1db2b8329d358b.zip
refactor update ssh key use time (#1466)
Diffstat (limited to 'models')
-rw-r--r--models/ssh_key.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go
index ba7007028f..75a0120c59 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -500,6 +500,20 @@ func UpdatePublicKey(key *PublicKey) error {
return err
}
+// UpdatePublicKeyUpdated updates public key use time.
+func UpdatePublicKeyUpdated(id int64) error {
+ cnt, err := x.ID(id).Cols("updated").Update(&PublicKey{
+ Updated: time.Now(),
+ })
+ if err != nil {
+ return err
+ }
+ if cnt != 1 {
+ return ErrKeyNotExist{id}
+ }
+ return nil
+}
+
// deletePublicKeys does the actual key deletion but does not update authorized_keys file.
func deletePublicKeys(e *xorm.Session, keyIDs ...int64) error {
if len(keyIDs) == 0 {