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

Method createSyncAppStoreMetaTask

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

Source from the content-addressed store, hash-verified

380}
381
382func (a AppService) createSyncAppStoreMetaTask(sharedCtx **appSyncContext) func(t *task.Task) error {
383 return func(t *task.Task) (err error) {
384 t.LogStart(i18n.GetMsgByKey("SyncAppDetail"))
385 ctx := *sharedCtx
386 if ctx == nil {
387 global.LOG.Warnf("[AppStore] meta sync skipped: shared context is nil")
388 t.Log(i18n.GetMsgByKey("SyncAppDetail") + " skipped: shared context is nil")
389 return nil
390 }
391
392 if ctx.skipMetaSync {
393 global.LOG.Infof("[AppStore] meta sync skipped: no update needed")
394 t.Log(i18n.GetMsgByKey("SyncAppDetail") + " skipped: no update needed")
395 return nil
396 }
397
398 if ctx.list == nil || ctx.appsMap == nil {
399 global.LOG.Errorf("[AppStore] meta sync failed: shared context data not initialized")
400 err := fmt.Errorf("shared context data not initialized")
401 t.LogFailedWithErr(i18n.GetMsgByKey("SyncAppDetail"), err)
402 return err
403 }
404
405 t.Logf("%s: %d apps", i18n.GetMsgByKey("SyncAppDetail"), len(ctx.list.Apps))
406
407 ctx.task = t
408 ctx.appTags = make([]*model.AppTag, 0)
409
410 if err = ctx.syncAppIconsAndDetails(); err != nil {
411 t.LogFailedWithErr(i18n.GetMsgByKey("SyncAppDetail"), err)
412 return err
413 }
414
415 if err = ctx.classifyAndPersistApps(); err != nil {
416 t.LogFailedWithErr(i18n.GetMsgByKey("PersistAppDetails"), err)
417 return err
418 }
419
420 global.LOG.Infof("[AppStore] Appstore meta sync completed")
421 return nil
422 }
423}
424
425func (c *appSyncContext) classifyAndPersistApps() (err error) {
426 var addCount, updateCount, deleteCount int

Callers 1

SyncAppListFromRemoteMethod · 0.95

Calls 6

LogStartMethod · 0.45
LogMethod · 0.45
LogFailedWithErrMethod · 0.45
LogfMethod · 0.45

Tested by

no test coverage detected