diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-12-19 00:26:26 +0800 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-12-18 11:26:26 -0500 |
commit | fe55ab2a6806b6a7c114378c0436bc59a31646d0 (patch) | |
tree | 43e0566e550b38596c6fb2ec6c0bf5adeeaad7f4 /models/ssh_key.go | |
parent | e726e4b828e9592085e6cf717a2e6c29b1c2d472 (diff) | |
download | gitea-fe55ab2a6806b6a7c114378c0436bc59a31646d0.tar.gz gitea-fe55ab2a6806b6a7c114378c0436bc59a31646d0.zip |
fix forgot removed records when deleting user (#5429)
* fix forgot removed records when deleting user
* fix migration
* fix rewritekey lock on sqlite
* remove unused codes
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 }) |