File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -316,13 +316,7 @@ func runServ(c *cli.Context) error {
316
316
317
317
// Update user key activity.
318
318
if keyID > 0 {
319
- key , err := models .GetPublicKeyByID (keyID )
320
- if err != nil {
321
- fail ("Internal error" , "GetPublicKeyById: %v" , err )
322
- }
323
-
324
- key .Updated = time .Now ()
325
- if err = models .UpdatePublicKey (key ); err != nil {
319
+ if err = models .UpdatePublicKeyUpdated (keyID ); err != nil {
326
320
fail ("Internal error" , "UpdatePublicKey: %v" , err )
327
321
}
328
322
}
Original file line number Diff line number Diff line change @@ -500,6 +500,20 @@ func UpdatePublicKey(key *PublicKey) error {
500
500
return err
501
501
}
502
502
503
+ // UpdatePublicKeyUpdated updates public key use time.
504
+ func UpdatePublicKeyUpdated (id int64 ) error {
505
+ cnt , err := x .ID (id ).Cols ("updated" ).Update (& PublicKey {
506
+ Updated : time .Now (),
507
+ })
508
+ if err != nil {
509
+ return err
510
+ }
511
+ if cnt != 1 {
512
+ return ErrKeyNotExist {id }
513
+ }
514
+ return nil
515
+ }
516
+
503
517
// deletePublicKeys does the actual key deletion but does not update authorized_keys file.
504
518
func deletePublicKeys (e * xorm.Session , keyIDs ... int64 ) error {
505
519
if len (keyIDs ) == 0 {
You can’t perform that action at this time.
0 commit comments