feat: let users delete policy-blocked and orphaned plugins

This commit is contained in:
goat 2022-07-13 21:29:01 +02:00
parent 098607cca8
commit 2c011b6bcd
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
3 changed files with 44 additions and 20 deletions

View file

@ -771,8 +771,8 @@ internal partial class PluginManager : IDisposable, IServiceType
/// <param name="plugin">Plugin to remove.</param>
public void RemovePlugin(LocalPlugin plugin)
{
if (plugin.State != PluginState.Unloaded)
throw new InvalidPluginOperationException($"Unable to remove {plugin.Name}, not unloaded");
if (plugin.State != PluginState.Unloaded && plugin.HasEverStartedLoad)
throw new InvalidPluginOperationException($"Unable to remove {plugin.Name}, not unloaded and had loaded before");
lock (this.pluginListLock)
{

View file

@ -189,6 +189,11 @@ internal class LocalPlugin : IDisposable
/// </summary>
public string BanReason { get; }
/// <summary>
/// Gets a value indicating whether the plugin has ever started to load.
/// </summary>
public bool HasEverStartedLoad { get; private set; }
/// <summary>
/// Gets a value indicating whether the plugin is loaded and running.
/// </summary>
@ -335,6 +340,8 @@ internal class LocalPlugin : IDisposable
"Please refer to https://github.com/goatcorp/Dalamud/discussions/603 for more information.");
}
this.HasEverStartedLoad = true;
this.loader ??= PluginLoader.CreateFromAssemblyFile(this.DllFile.FullName, SetupLoaderConfig);
if (reloading || this.IsDev)