diff options
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r-- | models/ssh_key.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go index b7dd81b49b..0f8e5225bb 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -549,6 +549,7 @@ func DeletePublicKey(doer *User, id int64) (err error) { if err = sess.Commit(); err != nil { return err } + sess.Close() return RewriteAllPublicKeys() } @@ -557,6 +558,10 @@ func DeletePublicKey(doer *User, id int64) (err error) { // Note: x.Iterate does not get latest data after insert/delete, so we have to call this function // outside any session scope independently. func RewriteAllPublicKeys() error { + return rewriteAllPublicKeys(x) +} + +func rewriteAllPublicKeys(e Engine) error { //Don't rewrite key if internal server if setting.SSH.StartBuiltinServer || !setting.SSH.CreateAuthorizedKeysFile { return nil @@ -583,7 +588,7 @@ func RewriteAllPublicKeys() error { } } - err = x.Iterate(new(PublicKey), func(idx int, bean interface{}) (err error) { + err = e.Iterate(new(PublicKey), func(idx int, bean interface{}) (err error) { _, err = t.WriteString((bean.(*PublicKey)).AuthorizedString()) return err }) |