(sharedCtx **appSyncContext)
| 380 | } |
| 381 | |
| 382 | func (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 | |
| 425 | func (c *appSyncContext) classifyAndPersistApps() (err error) { |
| 426 | var addCount, updateCount, deleteCount int |
no test coverage detected