Skip to content

Commit b8d8867

Browse files
feat(appstore): Restrict application updates based on the app's suppo… (#7174)
1 parent 7b1d746 commit b8d8867

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

backend/app/dto/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ type Tag struct {
109109
}
110110

111111
type AppForm struct {
112-
FormFields []AppFormFields `json:"formFields"`
112+
FormFields []AppFormFields `json:"formFields"`
113+
SupportVersion float64 `json:"supportVersion"`
113114
}
114115

115116
type AppFormFields struct {

backend/app/service/app.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,10 @@ func (a AppService) SyncAppListFromRemote() (err error) {
816816
}
817817
settingService := NewISettingService()
818818
_ = settingService.Update("AppStoreSyncStatus", constant.Syncing)
819-
819+
setting, err := settingService.GetSettingInfo()
820+
if err != nil {
821+
return err
822+
}
820823
var (
821824
tags []*model.Tag
822825
appTags []*model.AppTag
@@ -868,7 +871,13 @@ func (a AppService) SyncAppListFromRemote() (err error) {
868871
version := v.Name
869872
detail := detailsMap[version]
870873
versionUrl := fmt.Sprintf("%s/%s/%s", baseRemoteUrl, app.Key, version)
871-
874+
paramByte, _ := json.Marshal(v.AppForm)
875+
var appForm dto.AppForm
876+
_ = json.Unmarshal(paramByte, &appForm)
877+
if appForm.SupportVersion > 0 && common.CompareVersion(strconv.FormatFloat(appForm.SupportVersion, 'f', -1, 64), setting.SystemVersion) {
878+
delete(detailsMap, version)
879+
continue
880+
}
872881
if _, ok := InitTypes[app.Type]; ok {
873882
dockerComposeUrl := fmt.Sprintf("%s/%s", versionUrl, "docker-compose.yml")
874883
_, composeRes, err := httpUtil.HandleGetWithTransport(dockerComposeUrl, http.MethodGet, transport, constant.TimeOut20s)
@@ -880,7 +889,6 @@ func (a AppService) SyncAppListFromRemote() (err error) {
880889
detail.DockerCompose = ""
881890
}
882891

883-
paramByte, _ := json.Marshal(v.AppForm)
884892
detail.Params = string(paramByte)
885893
detail.DownloadUrl = fmt.Sprintf("%s/%s", versionUrl, app.Key+"-"+version+".tar.gz")
886894
detail.DownloadCallBackUrl = v.DownloadCallBackUrl

0 commit comments

Comments
 (0)