(root string, id string, pluginRuntime PluginRuntime)
| 247 | } |
| 248 | |
| 249 | func 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 | |
| 279 | func currentPluginFilePath(root string, id string) (string, error) { |
| 280 | paths, errPaths := pluginFilePaths(root, id) |
no test coverage detected