From 205e32dde842a9329da4d1e5bd89ec7f02eae193 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 18 May 2023 19:08:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=20(#1079?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app_utils.go | 13 ++++++++++--- backend/app/service/runtime.go | 8 +++++++- 2 files changed, 17 insertions(+), 4 deletions(-) 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) }