uninstall.go 734 B

1234567891011121314151617181920212223242526
  1. package plugin_manager
  2. import (
  3. "os"
  4. "path/filepath"
  5. "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
  6. )
  7. // UninstallFromLocal uninstalls a plugin from local storage
  8. // once deleted, local runtime will automatically shutdown and exit after several time
  9. func (p *PluginManager) UninstallFromLocal(identity plugin_entities.PluginUniqueIdentifier) error {
  10. plugin_installation_path := filepath.Join(p.pluginStoragePath, identity.String())
  11. if err := os.RemoveAll(plugin_installation_path); err != nil {
  12. return err
  13. }
  14. // send shutdown runtime
  15. runtime, ok := p.m.Load(identity.String())
  16. if !ok {
  17. // no runtime to shutdown, already uninstalled
  18. return nil
  19. }
  20. runtime.Shutdown()
  21. return nil
  22. }