fix: preserve legacy disabled state when loading a devplugin for the first time

This commit is contained in:
goat 2023-06-20 20:35:00 +02:00
parent 2e1ace6afd
commit 2e2a63b89e
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -694,6 +694,8 @@ internal partial class PluginManager : IDisposable, IServiceType
{ {
if (!setting.IsEnabled) if (!setting.IsEnabled)
continue; continue;
Log.Verbose("Scanning dev plugins at {Path}", setting.Path);
if (Directory.Exists(setting.Path)) if (Directory.Exists(setting.Path))
{ {
@ -1279,33 +1281,38 @@ internal partial class PluginManager : IDisposable, IServiceType
var wantsInDefaultProfile = var wantsInDefaultProfile =
this.profileManager.DefaultProfile.WantsPlugin(probablyInternalNameForThisPurpose); this.profileManager.DefaultProfile.WantsPlugin(probablyInternalNameForThisPurpose);
var wantsInAnyProfile = this.profileManager.GetWantState(probablyInternalNameForThisPurpose, false, false);
if (wantsInDefaultProfile == null) if (wantsInDefaultProfile == null)
{ {
// We don't know about this plugin, so we don't want to do anything here. // We don't know about this plugin, so we don't want to do anything here.
// The code below will take care of it and add it with the default value. // The code below will take care of it and add it with the default value.
if (!wantsInAnyProfile)
loadPlugin = false;
} }
else if (wantsInDefaultProfile == false && devPlugin.StartOnBoot) else if (wantsInDefaultProfile == false && devPlugin.StartOnBoot)
{ {
// 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. // 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", probablyInternalNameForThisPurpose);
this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false); this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false);
loadPlugin = false;
} }
else if (wantsInDefaultProfile == true && devPlugin.StartOnBoot) else if (wantsInDefaultProfile == true && devPlugin.StartOnBoot)
{ {
// We wanted this plugin, and StartOnBoot is on. That means we actually do want it. // We wanted this plugin, and StartOnBoot is on. That means we actually do want it.
Log.Verbose("DevPlugin {Name} enabled and StartOnBoot => enable", probablyInternalNameForThisPurpose);
this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, true, false); this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, true, false);
loadPlugin = !doNotLoad;
} }
else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot) else if (wantsInDefaultProfile == true && !devPlugin.StartOnBoot)
{ {
// We wanted this plugin, but StartOnBoot is off. This means we don't want it anymore. // We wanted this plugin, but StartOnBoot is off. This means we don't want it anymore.
Log.Verbose("DevPlugin {Name} enabled and !StartOnBoot => disable", probablyInternalNameForThisPurpose);
this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false); this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false);
loadPlugin = false;
} }
else if (wantsInDefaultProfile == false && !devPlugin.StartOnBoot) else if (wantsInDefaultProfile == false && !devPlugin.StartOnBoot)
{ {
// We didn't want this plugin, and StartOnBoot is off. We don't want it. // We didn't want this plugin, and StartOnBoot is off. We don't want it.
Log.Verbose("DevPlugin {Name} disabled and !StartOnBoot => disable", probablyInternalNameForThisPurpose);
this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false); this.profileManager.DefaultProfile.AddOrUpdate(probablyInternalNameForThisPurpose, false, false);
loadPlugin = false;
} }
plugin = devPlugin; plugin = devPlugin;