From ac0f69711160c87b910f498ebb6fe3fa179445bd Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:18:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=A4=9A=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=BA=94=E7=94=A8=E5=8D=87=E7=BA=A7=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#2090)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app.go | 6 +++--- backend/app/service/app_utils.go | 29 +++++++++++++++-------------- backend/app/service/setting.go | 7 +++++++ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index c5c4e9d80..c2d52a7e0 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -782,8 +782,8 @@ func (a AppService) SyncAppListFromRemote() (err error) { for _, v := range versions { version := v.Name detail := detailsMap[version] - - dockerComposeUrl := fmt.Sprintf("%s/%s/%s/%s", baseRemoteUrl, app.Key, version, "docker-compose.yml") + versionUrl := fmt.Sprintf("%s/%s/%s", baseRemoteUrl, app.Key, version) + dockerComposeUrl := fmt.Sprintf("%s/%s", versionUrl, "docker-compose.yml") composeRes, err := http.Get(dockerComposeUrl) if err != nil { return err @@ -796,7 +796,7 @@ func (a AppService) SyncAppListFromRemote() (err error) { paramByte, _ := json.Marshal(v.AppForm) detail.Params = string(paramByte) - detail.DownloadUrl = v.DownloadUrl + detail.DownloadUrl = fmt.Sprintf("%s/%s", versionUrl, app.Key+"-"+version+".tar.gz") detail.DownloadCallBackUrl = v.DownloadCallBackUrl detail.Update = true detail.LastModified = v.LastModified diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index a1cdcbe5a..3a071f6db 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -318,20 +318,21 @@ func upgradeInstall(installId uint, detailId uint, backup bool) error { return } servicesMap := value.(map[string]interface{}) - index := 0 - oldServiceName := "" - for k := range servicesMap { - oldServiceName = k - index++ - if index > 0 { - break + if len(servicesMap) == 1 { + index := 0 + oldServiceName := "" + for k := range servicesMap { + oldServiceName = k + index++ + if index > 0 { + break + } + } + servicesMap[install.ServiceName] = servicesMap[oldServiceName] + if install.ServiceName != oldServiceName { + delete(servicesMap, oldServiceName) } } - servicesMap[install.ServiceName] = servicesMap[oldServiceName] - if install.ServiceName != oldServiceName { - delete(servicesMap, oldServiceName) - } - envs := make(map[string]interface{}) if upErr = json.Unmarshal([]byte(install.Env), &envs); upErr != nil { return @@ -518,7 +519,7 @@ func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.App _ = fileOp.CreateDir(appVersionDir, 0755) } global.LOG.Infof("download app[%s] from %s", app.Name, appDetail.DownloadUrl) - filePath := path.Join(appVersionDir, appDetail.Version+".tar.gz") + filePath := path.Join(appVersionDir, app.Key+"-"+appDetail.Version+".tar.gz") defer func() { if err != nil { @@ -533,7 +534,7 @@ func downloadApp(app model.App, appDetail model.AppDetail, appInstall *model.App global.LOG.Errorf("download app[%s] error %v", app.Name, err) return } - if err = fileOp.Decompress(filePath, appVersionDir, files.TarGz); err != nil { + if err = fileOp.Decompress(filePath, appResourceDir, files.TarGz); err != nil { global.LOG.Errorf("decompress app[%s] error %v", app.Name, err) return } diff --git a/backend/app/service/setting.go b/backend/app/service/setting.go index a3f7f48da..e34e3064b 100644 --- a/backend/app/service/setting.go +++ b/backend/app/service/setting.go @@ -103,6 +103,12 @@ func (u *SettingService) Update(key, value string) error { if err := ntp.UpdateSystemTimeZone(value); err != nil { return err } + case "AppStoreLastModified": + exist, _ := settingRepo.Get(settingRepo.WithByKey("AppStoreLastModified")) + if exist.ID == 0 { + _ = settingRepo.Create("AppStoreLastModified", value) + return nil + } } if err := settingRepo.Update(key, value); err != nil { @@ -128,6 +134,7 @@ func (u *SettingService) Update(key, value string) error { } case "UserName", "Password": _ = global.SESSION.Clean() + } return nil