()
| 826 | } |
| 827 | |
| 828 | func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) { |
| 829 | res := &response.AppUpdateRes{ |
| 830 | CanUpdate: false, |
| 831 | } |
| 832 | mysql, _ := appRepo.GetFirst(appRepo.WithKey("mysql")) |
| 833 | if !mysql.BatchInstallSupport { |
| 834 | res.CanUpdate = true |
| 835 | return res, nil |
| 836 | } |
| 837 | |
| 838 | versionUrl := fmt.Sprintf("%s/%s/1panel.json.version.txt", global.AppRepoURL(), global.CONF.Base.Mode) |
| 839 | _, versionRes, err := req_helper.HandleRequest(versionUrl, http.MethodGet, constant.TimeOut20s) |
| 840 | if err != nil { |
| 841 | return nil, err |
| 842 | } |
| 843 | lastModifiedStr := string(versionRes) |
| 844 | lastModified, err := strconv.Atoi(lastModifiedStr) |
| 845 | if err != nil { |
| 846 | return nil, err |
| 847 | } |
| 848 | setting, err := NewISettingService().GetSettingInfo() |
| 849 | if err != nil { |
| 850 | return nil, err |
| 851 | } |
| 852 | if setting.AppStoreSyncStatus == constant.StatusSyncing { |
| 853 | res.IsSyncing = true |
| 854 | return res, nil |
| 855 | } |
| 856 | |
| 857 | appStoreLastModified, _ := strconv.Atoi(setting.AppStoreLastModified) |
| 858 | res.AppStoreLastModified = appStoreLastModified |
| 859 | if setting.AppStoreLastModified == "" || lastModified != appStoreLastModified { |
| 860 | res.CanUpdate = true |
| 861 | return res, err |
| 862 | } |
| 863 | apps, _ := appRepo.GetBy(appRepo.WithResource(constant.AppResourceRemote)) |
| 864 | for _, app := range apps { |
| 865 | if app.Icon == "" { |
| 866 | res.CanUpdate = true |
| 867 | return res, err |
| 868 | } |
| 869 | if appicon.IsIconFile(app.Icon) { |
| 870 | fileName, _ := appicon.ParseIconField(app.Icon) |
| 871 | if fileName == "" || !appicon.IconFileExists(fileName) { |
| 872 | res.CanUpdate = true |
| 873 | return res, err |
| 874 | } |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | list, err := getAppList() |
| 879 | if err != nil { |
| 880 | return res, err |
| 881 | } |
| 882 | if list.Extra.Version != "" && setting.SystemVersion != list.Extra.Version && !common.CompareVersion(setting.SystemVersion, list.Extra.Version) { |
| 883 | global.LOG.Errorf("The current version %s is too low to synchronize with the App Store. The minimum required version is %s", setting.SystemVersion, list.Extra.Version) |
| 884 | return nil, buserr.New("ErrVersionTooLow") |
| 885 | } |
no test coverage detected