MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / SyncPlatformWithReport

Function SyncPlatformWithReport

internal/homeplugins/sync.go:122–191  ·  view source on GitHub ↗
(ctx context.Context, cfg *config.Config, pluginRuntime PluginRuntime, platform Platform)

Source from the content-addressed store, hash-verified

120}
121
122func SyncPlatformWithReport(ctx context.Context, cfg *config.Config, pluginRuntime PluginRuntime, platform Platform) (SyncReport, error) {
123 if cfg == nil || !cfg.Home.Enabled || !cfg.Plugins.Enabled {
124 return newSyncReport(platform), nil
125 }
126 platform = NormalizePlatform(platform)
127 report := newSyncReport(platform)
128 if platform.GOOS == "" {
129 errPlatform := fmt.Errorf("home plugins: goos is required")
130 finishReport(&report, errPlatform)
131 return report, errPlatform
132 }
133 if platform.GOARCH == "" {
134 errPlatform := fmt.Errorf("home plugins: goarch is required")
135 finishReport(&report, errPlatform)
136 return report, errPlatform
137 }
138 report.Platform = platform
139 root := strings.TrimSpace(cfg.Plugins.Dir)
140 if root == "" {
141 root = "plugins"
142 }
143 client := newPluginStoreClient(cfg)
144 var syncErrors []error
145 ids := make([]string, 0, len(cfg.Plugins.Configs))
146 for id := range cfg.Plugins.Configs {
147 ids = append(ids, id)
148 }
149 sort.Strings(ids)
150 for _, id := range ids {
151 item := cfg.Plugins.Configs[id]
152 if !pluginConfigEnabled(item) {
153 continue
154 }
155 manifest, okManifest, errManifest := storeManifestFromPluginConfig(id, item)
156 if errManifest != nil {
157 status := PluginInstallStatus{
158 ID: strings.TrimSpace(id),
159 InstallStatus: pluginInstallStatusFailed,
160 Error: errManifest.Error(),
161 }
162 report.Plugins = append(report.Plugins, status)
163 syncErrors = append(syncErrors, errManifest)
164 continue
165 }
166 if !okManifest {
167 continue
168 }
169 status := pluginStatusFromManifest(manifest)
170 result, errSync := installManifest(ctx, client, manifest, root, platform, pluginRuntime)
171 if errSync != nil {
172 status.InstallStatus = pluginInstallStatusFailed
173 status.Error = errSync.Error()
174 report.Plugins = append(report.Plugins, status)
175 syncErrors = append(syncErrors, errSync)
176 continue
177 }
178 status.Path = strings.TrimSpace(result.Path)
179 status.Skipped = result.Skipped

Calls 8

newSyncReportFunction · 0.85
NormalizePlatformFunction · 0.85
finishReportFunction · 0.85
pluginConfigEnabledFunction · 0.85
pluginStatusFromManifestFunction · 0.85
installManifestFunction · 0.85
ErrorMethod · 0.45