fix: actually don't attempt to load plugins without manifests any longer

This commit is contained in:
goat 2023-10-03 23:37:02 +02:00
parent daeec9a13f
commit 4487ef85f4
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
3 changed files with 37 additions and 33 deletions

View file

@ -444,6 +444,11 @@ internal partial class PluginManager : IDisposable, IServiceType
continue;
var manifest = LocalPluginManifest.Load(manifestFile);
if (manifest == null)
{
Log.Error("Manifest for plugin at {Path} was null", dllFile.FullName);
continue;
}
if (manifest.IsTestingExclusive && this.configuration.PluginTestingOptIns!.All(x => x.InternalName != manifest.InternalName))
this.configuration.PluginTestingOptIns.Add(new PluginTestingOptIn(manifest.InternalName));
@ -490,9 +495,20 @@ internal partial class PluginManager : IDisposable, IServiceType
{
try
{
// Manifests are not required for devPlugins. the Plugin type will handle any null manifests.
// Manifests are now required for devPlugins
var manifestFile = LocalPluginManifest.GetManifestFile(dllFile);
var manifest = manifestFile.Exists ? LocalPluginManifest.Load(manifestFile) : null;
if (!manifestFile.Exists)
{
Log.Information("DLL at {DllPath} has no manifest, this is no longer valid", dllFile.FullName);
continue;
}
var manifest = LocalPluginManifest.Load(manifestFile);
if (manifest == null)
{
Log.Information("Could not deserialize manifest for DLL at {DllPath}", dllFile.FullName);
continue;
}
if (manifest != null && manifest.InternalName.IsNullOrEmpty())
{
@ -721,9 +737,20 @@ internal partial class PluginManager : IDisposable, IServiceType
continue;
}
// Manifests are not required for devPlugins. the Plugin type will handle any null manifests.
// Manifests are now required for devPlugins
var manifestFile = LocalPluginManifest.GetManifestFile(dllFile);
var manifest = manifestFile.Exists ? LocalPluginManifest.Load(manifestFile) : null;
if (!manifestFile.Exists)
{
Log.Information("DLL at {DllPath} has no manifest, this is no longer valid", dllFile.FullName);
continue;
}
var manifest = LocalPluginManifest.Load(manifestFile);
if (manifest == null)
{
Log.Information("Could not deserialize manifest for DLL at {DllPath}", dllFile.FullName);
continue;
}
try
{
@ -738,7 +765,7 @@ internal partial class PluginManager : IDisposable, IServiceType
}
catch (Exception ex)
{
Log.Error(ex, $"During devPlugin scan, an unexpected error occurred");
Log.Error(ex, "During devPlugin scan, an unexpected error occurred");
}
}
@ -1274,7 +1301,7 @@ internal partial class PluginManager : IDisposable, IServiceType
/// <param name="isBoot">If this plugin is being loaded at boot.</param>
/// <param name="doNotLoad">Don't load the plugin, just don't do it.</param>
/// <returns>The loaded plugin.</returns>
private async Task<LocalPlugin> LoadPluginAsync(FileInfo dllFile, LocalPluginManifest? manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
private async Task<LocalPlugin> LoadPluginAsync(FileInfo dllFile, LocalPluginManifest manifest, PluginLoadReason reason, bool isDev = false, bool isBoot = false, bool doNotLoad = false)
{
var name = manifest?.Name ?? dllFile.Name;
var loadPlugin = !doNotLoad;

View file

@ -51,7 +51,7 @@ internal class LocalPlugin : IDisposable
/// </summary>
/// <param name="dllFile">Path to the DLL file.</param>
/// <param name="manifest">The plugin manifest.</param>
public LocalPlugin(FileInfo dllFile, LocalPluginManifest? manifest)
public LocalPlugin(FileInfo dllFile, LocalPluginManifest manifest)
{
if (dllFile.Name == "FFXIVClientStructs.Generators.dll")
{
@ -66,30 +66,7 @@ internal class LocalPlugin : IDisposable
// Although it is conditionally used here, we need to set the initial value regardless.
this.manifestFile = LocalPluginManifest.GetManifestFile(this.DllFile);
// If the parameter manifest was null
if (manifest == null)
{
this.manifest = new LocalPluginManifest()
{
Author = "developer",
Name = Path.GetFileNameWithoutExtension(this.DllFile.Name),
InternalName = Path.GetFileNameWithoutExtension(this.DllFile.Name),
AssemblyVersion = new Version("1.0.0.0"),
Description = string.Empty,
ApplicableVersion = GameVersion.Any,
DalamudApiLevel = PluginManager.DalamudApiLevel,
IsHide = false,
};
// Save the manifest to disk so there won't be any problems later.
// We'll update the name property after it can be retrieved from the instance.
this.manifest.Save(this.manifestFile, "manifest was null");
}
else
{
this.manifest = manifest;
}
this.manifest = manifest;
var needsSaveDueToLegacyFiles = false;

View file

@ -15,7 +15,7 @@ internal struct PluginDef
/// <param name="dllFile">plugin dll file.</param>
/// <param name="manifest">plugin manifest.</param>
/// <param name="isDev">plugin dev indicator.</param>
public PluginDef(FileInfo dllFile, LocalPluginManifest? manifest, bool isDev)
public PluginDef(FileInfo dllFile, LocalPluginManifest manifest, bool isDev)
{
this.DllFile = dllFile;
this.Manifest = manifest;
@ -30,7 +30,7 @@ internal struct PluginDef
/// <summary>
/// Gets plugin manifest.
/// </summary>
public LocalPluginManifest? Manifest { get; init; }
public LocalPluginManifest Manifest { get; init; }
/// <summary>
/// Gets a value indicating whether plugin is a dev plugin.