diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 41fbfe9f1..c948a16ad 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -535,6 +535,12 @@ func (a *AppInstallService) GetUpdateVersions(req request.AppUpdateVersion) ([]d if err != nil { return versions, err } + if app.Key == constant.AppMysql { + majorVersion := getMajorVersion(install.Version) + if !strings.HasPrefix(detail.Version, majorVersion) { + continue + } + } versions = append(versions, dto.AppVersion{ Version: detail.Version, DetailId: detail.ID, diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 1197f46c0..06835b0ff 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -1235,6 +1235,31 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI _ = appInstallRepo.Save(context.Background(), appInstall) } +func getMajorVersion(version string) string { + parts := strings.Split(version, ".") + if len(parts) >= 2 { + return parts[0] + "." + parts[1] + } + return version +} + +func ignoreUpdate(installed model.AppInstall) bool { + if installed.App.Type == "php" || installed.Status == constant.Installing { + return true + } + if installed.App.Key == constant.AppMysql { + majorVersion := getMajorVersion(installed.Version) + appDetails, _ := appDetailRepo.GetBy(appDetailRepo.WithAppId(installed.App.ID)) + for _, appDetail := range appDetails { + if strings.HasPrefix(appDetail.Version, majorVersion) && common.CompareVersion(appDetail.Version, installed.Version) { + return false + } + } + return true + } + return false +} + func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool) ([]response.AppInstallDTO, error) { var ( res []response.AppInstallDTO @@ -1257,7 +1282,7 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool) } for _, installed := range appInstallList { - if updated && (installed.App.Type == "php" || installed.Status == constant.Installing || (installed.App.Key == constant.AppMysql && installed.Version == "5.6.51")) { + if updated && ignoreUpdate(installed) { continue } if sync && !doNotNeedSync(installed) {