From 923381becd08b5491d90ff3380e060c34b3c0eab Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 6 Aug 2019 00:09:57 +0800 Subject: [PATCH] fix rename failed when rewrite public keys --- models/ssh_key.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/ssh_key.go b/models/ssh_key.go index b2a905305ac40..4f93b5c44f5d1 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -685,12 +685,14 @@ func rewriteAllPublicKeys(e Engine) error { } _, err = t.WriteString(line + "\n") if err != nil { + f.Close() return err } } - defer f.Close() + f.Close() } + t.Close() return os.Rename(tmpPath, fPath) }