Skip to content

Commit d330a23

Browse files
lunnyappleboy
authored andcommitted
fix migration failed when authorized_keys is not exist (#1180)
1 parent d349f05 commit d330a23

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

models/migrations/v21.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/modules/setting"
1313

14+
"github.com/Unknwon/com"
1415
"github.com/go-xorm/xorm"
1516
)
1617

@@ -21,6 +22,10 @@ const (
2122

2223
func useNewPublickeyFormat(x *xorm.Engine) error {
2324
fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys")
25+
if !com.IsExist(fpath) {
26+
return nil
27+
}
28+
2429
tmpPath := fpath + ".tmp"
2530
f, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
2631
if err != nil {

0 commit comments

Comments
 (0)