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

Function deletePluginArtifact

internal/homeplugins/sync.go:249–277  ·  view source on GitHub ↗
(root string, id string, pluginRuntime PluginRuntime)

Source from the content-addressed store, hash-verified

247}
248
249func deletePluginArtifact(root string, id string, pluginRuntime PluginRuntime) (string, bool, error) {
250 id = strings.TrimSpace(id)
251 if !validPluginFileID(id) {
252 return "", false, fmt.Errorf("invalid plugin id %q", id)
253 }
254 paths, errPaths := pluginFilePaths(root, id)
255 if errPaths != nil {
256 return "", false, errPaths
257 }
258 if len(paths) == 0 {
259 return "", false, nil
260 }
261 if pluginRuntime != nil && pluginRuntime.PluginBusy(id) {
262 if !pluginRuntime.UnloadPlugin(id) && pluginRuntime.PluginBusy(id) {
263 return paths[0], false, sdkpluginstore.ErrLoadedPluginLocked
264 }
265 }
266 deleted := false
267 for _, path := range paths {
268 if errRemove := os.Remove(path); errRemove != nil {
269 if errors.Is(errRemove, os.ErrNotExist) {
270 continue
271 }
272 return paths[0], deleted, errRemove
273 }
274 deleted = true
275 }
276 return paths[0], deleted, nil
277}
278
279func currentPluginFilePath(root string, id string) (string, error) {
280 paths, errPaths := pluginFilePaths(root, id)

Callers 1

DeleteWithReportFunction · 0.85

Calls 5

validPluginFileIDFunction · 0.85
pluginFilePathsFunction · 0.85
RemoveMethod · 0.80
PluginBusyMethod · 0.65
UnloadPluginMethod · 0.65

Tested by

no test coverage detected