mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 20:33:40 +01:00
feat: add failing plugins to the installer during boot, handle dependency resolution failures
This commit is contained in:
parent
716736f022
commit
d9c38a9813
4 changed files with 48 additions and 9 deletions
|
|
@ -734,13 +734,23 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
{
|
||||
// Dev plugins always get added to the list so they can be fiddled with in the UI
|
||||
Log.Information(ex, $"Dev plugin failed to load, adding anyways: {dllFile.Name}");
|
||||
plugin.Disable(); // Disable here, otherwise you can't enable+load later
|
||||
|
||||
// NOTE(goat): This can't work - plugins don't "unload" if they fail to load.
|
||||
// plugin.Disable(); // Disable here, otherwise you can't enable+load later
|
||||
}
|
||||
else if (plugin.IsOutdated)
|
||||
{
|
||||
// Out of date plugins get added so they can be updated.
|
||||
Log.Information(ex, $"Plugin was outdated, adding anyways: {dllFile.Name}");
|
||||
}
|
||||
else if (isBoot)
|
||||
{
|
||||
// During boot load, plugins always get added to the list so they can be fiddled with in the UI
|
||||
Log.Information(ex, $"Regular plugin failed to load, adding anyways: {dllFile.Name}");
|
||||
|
||||
// NOTE(goat): This can't work - plugins don't "unload" if they fail to load.
|
||||
// plugin.Disable(); // Disable here, otherwise you can't enable+load later
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginLocations.Remove(plugin.AssemblyName?.FullName ?? string.Empty, out _);
|
||||
|
|
@ -919,7 +929,7 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
if (!dryRun)
|
||||
{
|
||||
// Unload if loaded
|
||||
if (plugin.State == PluginState.Loaded || plugin.State == PluginState.LoadError)
|
||||
if (plugin.State is PluginState.Loaded or PluginState.LoadError or PluginState.DependencyResolutionFailed)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,7 +55,16 @@ internal class LocalPlugin : IDisposable
|
|||
this.DllFile = dllFile;
|
||||
this.State = PluginState.Unloaded;
|
||||
|
||||
this.loader = PluginLoader.CreateFromAssemblyFile(this.DllFile.FullName, SetupLoaderConfig);
|
||||
try
|
||||
{
|
||||
this.loader = PluginLoader.CreateFromAssemblyFile(this.DllFile.FullName, SetupLoaderConfig);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
Log.Error(ex, "Loader.CreateFromAssemblyFile() failed");
|
||||
this.State = PluginState.DependencyResolutionFailed;
|
||||
throw;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -522,6 +531,8 @@ internal class LocalPlugin : IDisposable
|
|||
break;
|
||||
case PluginState.UnloadError:
|
||||
break;
|
||||
case PluginState.DependencyResolutionFailed:
|
||||
throw new InvalidPluginOperationException($"Unable to enable {this.Name}, dependency resolution failed");
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(this.State.ToString());
|
||||
}
|
||||
|
|
@ -550,6 +561,8 @@ internal class LocalPlugin : IDisposable
|
|||
break;
|
||||
case PluginState.UnloadError:
|
||||
break;
|
||||
case PluginState.DependencyResolutionFailed:
|
||||
return; // This is a no-op.
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(this.State.ToString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,4 +34,9 @@ internal enum PluginState
|
|||
/// Currently loading.
|
||||
/// </summary>
|
||||
Loading,
|
||||
|
||||
/// <summary>
|
||||
/// This plugin couldn't load one of its dependencies.
|
||||
/// </summary>
|
||||
DependencyResolutionFailed,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue