(TaskID string)
| 594 | } |
| 595 | |
| 596 | func (a AppService) SyncAppListFromLocal(TaskID string) { |
| 597 | var ( |
| 598 | err error |
| 599 | dirEntries []os.DirEntry |
| 600 | localApps []model.App |
| 601 | ) |
| 602 | |
| 603 | syncTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("LocalApp"), task.TaskSync, task.TaskScopeAppStore, TaskID, 0) |
| 604 | if err != nil { |
| 605 | global.LOG.Errorf("Create sync task failed %v", err) |
| 606 | return |
| 607 | } |
| 608 | |
| 609 | syncTask.AddSubTask(task.GetTaskName(i18n.GetMsgByKey("LocalApp"), task.TaskSync, task.TaskScopeAppStore), func(t *task.Task) (err error) { |
| 610 | fileOp := files.NewFileOp() |
| 611 | localAppDir := global.Dir.LocalAppResourceDir |
| 612 | if !fileOp.Stat(localAppDir) { |
| 613 | return nil |
| 614 | } |
| 615 | dirEntries, err = os.ReadDir(localAppDir) |
| 616 | if err != nil { |
| 617 | return |
| 618 | } |
| 619 | for _, dirEntry := range dirEntries { |
| 620 | if dirEntry.IsDir() { |
| 621 | appDir := filepath.Join(localAppDir, dirEntry.Name()) |
| 622 | appDirEntries, err := os.ReadDir(appDir) |
| 623 | if err != nil { |
| 624 | t.Log(i18n.GetWithNameAndErr("ErrAppDirNull", dirEntry.Name(), err)) |
| 625 | continue |
| 626 | } |
| 627 | app, err := handleLocalApp(appDir) |
| 628 | if err != nil { |
| 629 | t.Log(i18n.GetWithNameAndErr("LocalAppErr", dirEntry.Name(), err)) |
| 630 | continue |
| 631 | } |
| 632 | var appDetails []model.AppDetail |
| 633 | for _, appDirEntry := range appDirEntries { |
| 634 | if appDirEntry.IsDir() { |
| 635 | appDetail := model.AppDetail{ |
| 636 | Version: appDirEntry.Name(), |
| 637 | Status: constant.AppNormal, |
| 638 | } |
| 639 | versionDir := filepath.Join(appDir, appDirEntry.Name()) |
| 640 | if err = handleLocalAppDetail(versionDir, &appDetail); err != nil { |
| 641 | t.Log(i18n.GetMsgWithMap("LocalAppVersionErr", map[string]interface{}{"name": app.Name, "version": appDetail.Version, "err": err.Error()})) |
| 642 | continue |
| 643 | } |
| 644 | appDetails = append(appDetails, appDetail) |
| 645 | } |
| 646 | } |
| 647 | if len(appDetails) > 0 { |
| 648 | app.Details = appDetails |
| 649 | localApps = append(localApps, *app) |
| 650 | } else { |
| 651 | t.Log(i18n.GetWithName("LocalAppVersionNull", app.Name)) |
| 652 | } |
| 653 | } |
nothing calls this directly
no test coverage detected