track internal name nonetheless

This commit is contained in:
goaaats 2024-01-18 22:47:56 +01:00
parent 256f4989f7
commit 9024c9b00c
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
6 changed files with 21 additions and 18 deletions

View file

@ -1511,28 +1511,28 @@ internal partial class PluginManager : IDisposable, IServiceType
{
// We didn't want this plugin, and StartOnBoot is on. That means we don't want it and it should stay off until manually enabled.
Log.Verbose("DevPlugin {Name} disabled and StartOnBoot => disable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, false, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
loadPlugin = false;
}
else if (wantsInDefaultProfile == true && devPlugin.StartOnBoot)
{
// We wanted this plugin, and StartOnBoot is on. That means we actually do want it.
Log.Verbose("DevPlugin {Name} enabled and StartOnBoot => enable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, true, false);
loadPlugin = !doNotLoad;
}
else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot)
{
// We wanted this plugin, but StartOnBoot is off. This means we don't want it anymore.
Log.Verbose("DevPlugin {Name} enabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, false, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
loadPlugin = false;
}
else if (wantsInDefaultProfile == false && !devPlugin.StartOnBoot)
{
// We didn't want this plugin, and StartOnBoot is off. We don't want it.
Log.Verbose("DevPlugin {Name} disabled and !StartOnBoot => disable", plugin.Manifest.InternalName);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, false, false);
await this.profileManager.DefaultProfile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, false, false);
loadPlugin = false;
}
@ -1544,7 +1544,7 @@ internal partial class PluginManager : IDisposable, IServiceType
#pragma warning restore CS0618
// Need to do this here, so plugins that don't load are still added to the default profile
var wantToLoad = await this.profileManager.GetWantStateAsync(plugin.Manifest.WorkingPluginId, defaultState);
var wantToLoad = await this.profileManager.GetWantStateAsync(plugin.Manifest.WorkingPluginId, plugin.Manifest.InternalName, defaultState);
if (loadPlugin)
{

View file

@ -158,10 +158,11 @@ internal class Profile
/// This will block until all states have been applied.
/// </summary>
/// <param name="workingPluginId">The ID of the plugin.</param>
/// <param name="internalName">The internal name of the plugin, if available.</param>
/// <param name="state">Whether or not the plugin should be enabled.</param>
/// <param name="apply">Whether or not the current state should immediately be applied.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task AddOrUpdateAsync(Guid workingPluginId, bool state, bool apply = true)
public async Task AddOrUpdateAsync(Guid workingPluginId, string? internalName, bool state, bool apply = true)
{
Debug.Assert(workingPluginId != Guid.Empty, "Trying to add plugin with empty guid");
@ -176,6 +177,7 @@ internal class Profile
{
this.modelV1.Plugins.Add(new ProfileModelV1.ProfileModelV1Plugin
{
InternalName = internalName,
WorkingPluginId = workingPluginId,
IsEnabled = state,
});
@ -219,7 +221,7 @@ internal class Profile
{
if (!this.IsDefaultProfile)
{
await this.manager.DefaultProfile.AddOrUpdateAsync(workingPluginId, this.IsEnabled && entry.IsEnabled, false);
await this.manager.DefaultProfile.AddOrUpdateAsync(workingPluginId, entry.InternalName, this.IsEnabled && entry.IsEnabled, false);
}
else
{

View file

@ -70,10 +70,11 @@ internal class ProfileManager : IServiceType
/// Check if any enabled profile wants a specific plugin enabled.
/// </summary>
/// <param name="workingPluginId">The ID of the plugin.</param>
/// <param name="internalName">The internal name of the plugin, if available.</param>
/// <param name="defaultState">The state the plugin shall be in, if it needs to be added.</param>
/// <param name="addIfNotDeclared">Whether or not the plugin should be added to the default preset, if it's not present in any preset.</param>
/// <returns>Whether or not the plugin shall be enabled.</returns>
public async Task<bool> GetWantStateAsync(Guid workingPluginId, bool defaultState, bool addIfNotDeclared = true)
public async Task<bool> GetWantStateAsync(Guid workingPluginId, string? internalName, bool defaultState, bool addIfNotDeclared = true)
{
var want = false;
var wasInAnyProfile = false;
@ -93,8 +94,8 @@ internal class ProfileManager : IServiceType
if (!wasInAnyProfile && addIfNotDeclared)
{
Log.Warning("{Guid} was not in any profile, adding to default with {Default}", workingPluginId, defaultState);
await this.DefaultProfile.AddOrUpdateAsync(workingPluginId, defaultState, false);
Log.Warning("'{Guid}'('{InternalName}') was not in any profile, adding to default with {Default}", workingPluginId, internalName, defaultState);
await this.DefaultProfile.AddOrUpdateAsync(workingPluginId, internalName, defaultState, false);
return defaultState;
}

View file

@ -164,7 +164,7 @@ internal class LocalPlugin : IDisposable
/// INCLUDES the default profile.
/// </summary>
public bool IsWantedByAnyProfile =>
Service<ProfileManager>.Get().GetWantStateAsync(this.manifest.WorkingPluginId, false, false).GetAwaiter().GetResult();
Service<ProfileManager>.Get().GetWantStateAsync(this.manifest.WorkingPluginId, this.Manifest.InternalName, false, false).GetAwaiter().GetResult();
/// <summary>
/// Gets a value indicating whether this plugin's API level is out of date.