diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 6232f324c..ce833bcc3 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -236,7 +236,7 @@ func upgradeInstall(installId uint, detailId uint) error { defer func() { if upErr != nil { install.Status = constant.UpgradeErr - install.Message = err.Error() + install.Message = upErr.Error() _ = appInstallRepo.Save(context.Background(), &install) } }() @@ -318,6 +318,11 @@ func upgradeInstall(installId uint, detailId uint) error { return } fileOp := files.NewFileOp() + envParams := make(map[string]string, len(envs)) + handleMap(envs, envParams) + if err = env.Write(envParams, install.GetEnvPath()); err != nil { + return + } if upErr = fileOp.WriteFile(install.GetComposePath(), strings.NewReader(install.DockerCompose), 0775); upErr != nil { return } @@ -424,8 +429,10 @@ func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.App defer func() { if err != nil { - appInstall.Status = constant.DownloadErr - appInstall.Message = err.Error() + if appInstall != nil { + appInstall.Status = constant.DownloadErr + appInstall.Message = err.Error() + } } }() diff --git a/backend/app/service/runtime.go b/backend/app/service/runtime.go index 8e3e427bc..74ed4945e 100644 --- a/backend/app/service/runtime.go +++ b/backend/app/service/runtime.go @@ -64,7 +64,13 @@ func (r *RuntimeService) Create(create request.RuntimeCreate) (err error) { return err } fileOp := files.NewFileOp() - buildDir := path.Join(constant.AppResourceDir, app.Key, "versions", appDetail.Version, "build") + appVersionDir := path.Join(constant.AppResourceDir, app.Resource, app.Key, appDetail.Version) + if !fileOp.Stat(appVersionDir) { + if err := downloadApp(app, appDetail, nil); err != nil { + return err + } + } + buildDir := path.Join(appVersionDir, "build") if !fileOp.Stat(buildDir) { return buserr.New(constant.ErrDirNotFound) }