MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / GetAppUpdate

Method GetAppUpdate

agent/app/service/app.go:828–888  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

826}
827
828func (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 }

Callers 1

Calls 7

getAppListFunction · 0.85
NewISettingServiceFunction · 0.70
GetFirstMethod · 0.65
WithKeyMethod · 0.65
GetSettingInfoMethod · 0.65
GetByMethod · 0.65
WithResourceMethod · 0.65

Tested by

no test coverage detected