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

Method SyncAppListFromRemote

agent/app/service/app.go:968–1021  ·  view source on GitHub ↗
(taskID string)

Source from the content-addressed store, hash-verified

966}
967
968func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
969 if xpack.MultiNodeProvider.IsUseCustomApp() {
970 return nil
971 }
972
973 appStoreSyncMu.Lock()
974 global.LOG.Info("[AppStore] sync app from remote task create start")
975 if appStoreSyncing {
976 appStoreSyncMu.Unlock()
977 global.LOG.Info("[AppStore] sync already in progress, skipping")
978 return nil
979 }
980 appStoreSyncing = true
981 appStoreSyncMu.Unlock()
982
983 syncTask, err := task.NewTaskWithOps(i18n.GetMsgByKey("App"), task.TaskSync, task.TaskScopeAppStore, taskID, 0)
984 if err != nil {
985 appStoreSyncMu.Lock()
986 appStoreSyncing = false
987 appStoreSyncMu.Unlock()
988 return err
989 }
990
991 var sharedCtx *appSyncContext
992
993 syncTask.AddSubTask(task.GetTaskName(i18n.GetMsgByKey("App"), task.TaskSync, task.TaskScopeAppStore), a.createSyncAppStoreTask(&sharedCtx), nil)
994 syncTask.AddSubTask(i18n.GetMsgByKey("SyncAppDetail"), a.createSyncAppStoreMetaTask(&sharedCtx), nil)
995
996 go func() {
997 defer func() {
998 if r := recover(); r != nil {
999 global.LOG.Errorf("[AppStore] sync goroutine recovered from panic: %v", r)
1000 if updateErr := NewISettingService().Update("AppStoreSyncStatus", constant.StatusError); updateErr != nil {
1001 global.LOG.Warnf("[AppStore] failed to update sync status after panic: %v", updateErr)
1002 }
1003 }
1004 appStoreSyncMu.Lock()
1005 appStoreSyncing = false
1006 appStoreSyncMu.Unlock()
1007 }()
1008 if err := syncTask.Execute(); err != nil {
1009 if updateErr := NewISettingService().Update("AppStoreLastModified", "0"); updateErr != nil {
1010 global.LOG.Warnf("[AppStore] failed to reset last modified: %v", updateErr)
1011 }
1012 if updateErr := NewISettingService().Update("AppStoreSyncStatus", constant.StatusError); updateErr != nil {
1013 global.LOG.Warnf("[AppStore] failed to update sync status to error: %v", updateErr)
1014 }
1015 return
1016 }
1017 }()
1018
1019 global.LOG.Info("[AppStore] sync app from remote task create ok")
1020 return nil
1021}
1022
1023func (a AppService) GetAppIcon(key string) ([]byte, string, string, error) {
1024 app, err := appRepo.GetFirst(appRepo.WithKey(key))

Callers

nothing calls this directly

Calls 7

NewISettingServiceFunction · 0.70
IsUseCustomAppMethod · 0.65
UpdateMethod · 0.65
AddSubTaskMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected