From d9bdf7a65d1c5f6ef314d148dc1b2f4d555d9254 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 23 Mar 2017 23:07:30 +0800 Subject: [PATCH] fix migration failed when authorized_keys is not exist (#1375) * fix wiki bugs (#1294) * fix migration failed when authorized_keys is not exist --- models/migrations/v21.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/models/migrations/v21.go b/models/migrations/v21.go index f7f01f062..e049727cb 100644 --- a/models/migrations/v21.go +++ b/models/migrations/v21.go @@ -11,6 +11,7 @@ import ( "code.gitea.io/gitea/modules/setting" + "github.com/Unknwon/com" "github.com/go-xorm/xorm" ) @@ -21,6 +22,10 @@ const ( func useNewPublickeyFormat(x *xorm.Engine) error { fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys") + if !com.IsExist(fpath) { + return nil + } + tmpPath := fpath + ".tmp" f, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil {