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

Function DeleteWithReport

internal/homeplugins/sync.go:213–247  ·  view source on GitHub ↗
(ctx context.Context, cfg *config.Config, pluginRuntime PluginRuntime, taskID uint, pluginID string)

Source from the content-addressed store, hash-verified

211}
212
213func DeleteWithReport(ctx context.Context, cfg *config.Config, pluginRuntime PluginRuntime, taskID uint, pluginID string) SyncReport {
214 _ = ctx
215 platform := CurrentPlatform()
216 report := newSyncReport(platform)
217 report.TaskID = taskID
218 report.Task = pluginDeleteTaskName
219 report.Phase = pluginTaskPhaseDelete
220 pluginID = strings.TrimSpace(pluginID)
221 status := PluginInstallStatus{ID: pluginID}
222 if cfg == nil {
223 status.InstallStatus = pluginInstallStatusFailed
224 status.Error = "home plugins: config is nil"
225 report.Plugins = append(report.Plugins, status)
226 finishReport(&report, errors.New(status.Error))
227 return report
228 }
229 root := strings.TrimSpace(cfg.Plugins.Dir)
230 if root == "" {
231 root = "plugins"
232 }
233 path, deleted, errDelete := deletePluginArtifact(root, pluginID, pluginRuntime)
234 status.Path = strings.TrimSpace(path)
235 switch {
236 case errDelete != nil:
237 status.InstallStatus = pluginInstallStatusFailed
238 status.Error = errDelete.Error()
239 case deleted:
240 status.InstallStatus = pluginInstallStatusDeleted
241 default:
242 status.InstallStatus = pluginInstallStatusMissing
243 }
244 report.Plugins = append(report.Plugins, status)
245 finishReport(&report, errDelete)
246 return report
247}
248
249func deletePluginArtifact(root string, id string, pluginRuntime PluginRuntime) (string, bool, error) {
250 id = strings.TrimSpace(id)

Calls 5

CurrentPlatformFunction · 0.85
newSyncReportFunction · 0.85
finishReportFunction · 0.85
deletePluginArtifactFunction · 0.85
ErrorMethod · 0.45