]> source.dussan.org Git - gitea.git/commitdiff
fix migration failed when authorized_keys is not exist (#1180)
authorLunny Xiao <xiaolunwen@gmail.com>
Wed, 22 Mar 2017 16:04:31 +0000 (00:04 +0800)
committerBo-Yi Wu <appleboy.tw@gmail.com>
Wed, 22 Mar 2017 16:04:31 +0000 (00:04 +0800)
models/migrations/v21.go

index f7f01f062b750c03e084739035559cbc138f37bb..e049727cbeebebdbaf83830e3ab87d74bed73a73 100644 (file)
@@ -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 {