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

Method createSyncAppStoreTask

agent/app/service/app_sync_task.go:40–130  ·  view source on GitHub ↗
(sharedCtx **appSyncContext)

Source from the content-addressed store, hash-verified

38}
39
40func (a AppService) createSyncAppStoreTask(sharedCtx **appSyncContext) func(t *task.Task) error {
41 return func(t *task.Task) (err error) {
42 t.LogStart(i18n.GetMsgByKey("AppStore") + " " + i18n.GetMsgByKey("TaskSync"))
43
44 updateRes, err := a.GetAppUpdate()
45 if err != nil {
46 t.LogFailedWithErr(i18n.GetMsgByKey("CheckAppStoreUpdate"), err)
47 return err
48 }
49 if !updateRes.CanUpdate {
50 if updateRes.IsSyncing {
51 t.Log(i18n.GetMsgByKey("AppStoreIsSyncing"))
52 return nil
53 }
54 global.LOG.Infof("[AppStore] Appstore is up to date")
55 t.Log(i18n.GetMsgByKey("AppStoreIsUpToDate"))
56 *sharedCtx = &appSyncContext{skipMetaSync: true}
57 t.LogSuccess(i18n.GetMsgByKey("AppStore") + " " + i18n.GetMsgByKey("TaskSync"))
58 return nil
59 }
60
61 list := &dto.AppList{}
62 if updateRes.AppList == nil {
63 list, err = getAppList()
64 if err != nil {
65 t.LogFailedWithErr(i18n.GetMsgByKey("DownloadAppList"), err)
66 return err
67 }
68 } else {
69 list = updateRes.AppList
70 }
71
72 settingService := NewISettingService()
73 if err := settingService.Update("AppStoreSyncStatus", constant.StatusSyncing); err != nil {
74 global.LOG.Warnf("[AppStore] failed to update sync status to syncing: %v", err)
75 }
76
77 setting, err := settingService.GetSettingInfo()
78 if err != nil {
79 t.LogFailedWithErr("GetSettingInfo", err)
80 return err
81 }
82
83 ctx := &appSyncContext{
84 task: t,
85 httpClient: http.Client{Timeout: time.Duration(constant.TimeOut20s) * time.Second, Transport: xpack.MultiNodeProvider.LoadRequestTransport()},
86 baseRemoteUrl: fmt.Sprintf("%s/%s/1panel", global.AppRepoURL(), global.CONF.Base.Mode),
87 systemVersion: setting.SystemVersion,
88 settingService: settingService,
89 list: list,
90 appTags: make([]*model.AppTag, 0),
91 pendingIcons: make(map[string]string),
92 }
93
94 if err = SyncTags(list.Extra); err != nil {
95 t.LogFailedWithErr(i18n.GetMsgByKey("SyncTags"), err)
96 return err
97 }

Callers 1

SyncAppListFromRemoteMethod · 0.95

Calls 15

GetAppUpdateMethod · 0.95
UpdateMethod · 0.95
GetSettingInfoMethod · 0.95
getAppListFunction · 0.85
SyncTagsFunction · 0.85
deleteCustomAppFunction · 0.85
getAppsFunction · 0.85
NewISettingServiceFunction · 0.70
LoadRequestTransportMethod · 0.65
GetByMethod · 0.65
WithNotLocalMethod · 0.65

Tested by

no test coverage detected