Skip to content

Commit 837dacb

Browse files
fix: resolve migration failure when reinstalling OpenResty
1 parent 289e419 commit 837dacb

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

agent/app/service/app_utils.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,23 +2016,26 @@ func handleSiteDir(app model.App, appDetail model.AppDetail, req request.AppInst
20162016
req.Params["WEBSITE_DIR"] = siteDir
20172017
oldWebStePath, _ := settingRepo.GetValueByKey("WEBSITE_DIR")
20182018
fileOp := files.NewFileOp()
2019+
movePath := func(src, dst string) error {
2020+
return cmd.NewCommandMgr().Run("mv", src, dst)
2021+
}
20192022
if oldWebStePath != "" && oldWebStePath != siteDir && fileOp.Stat(oldWebStePath) {
20202023
t.Log(i18n.GetWithName("MoveSiteDir", siteDir))
20212024
if fileOp.Stat(siteDir) {
20222025
if fileOp.Stat(path.Join(siteDir, "conf.d")) {
2023-
_ = fileOp.Rename(path.Join(siteDir, "conf.d"), path.Join(siteDir, "conf.d.bak"))
2026+
_ = movePath(path.Join(siteDir, "conf.d"), path.Join(siteDir, "conf.d.bak"))
20242027
}
20252028
if fileOp.Stat(path.Join(siteDir, "sites")) {
2026-
_ = fileOp.Rename(path.Join(siteDir, "sites"), path.Join(siteDir, "sites.bak"))
2029+
_ = movePath(path.Join(siteDir, "sites"), path.Join(siteDir, "sites.bak"))
20272030
}
2028-
if err := fileOp.Rename(path.Join(oldWebStePath, "sites"), path.Join(siteDir, "sites")); err != nil {
2031+
if err := movePath(path.Join(oldWebStePath, "sites"), path.Join(siteDir, "sites")); err != nil {
20292032
return err
20302033
}
2031-
if err := fileOp.Rename(path.Join(oldWebStePath, "conf.d"), path.Join(siteDir, "conf.d")); err != nil {
2034+
if err := movePath(path.Join(oldWebStePath, "conf.d"), path.Join(siteDir, "conf.d")); err != nil {
20322035
return err
20332036
}
20342037
} else {
2035-
err := fileOp.Rename(oldWebStePath, siteDir)
2038+
err := movePath(oldWebStePath, siteDir)
20362039
if err != nil {
20372040
return err
20382041
}

0 commit comments

Comments
 (0)