mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
fix: ignore the default profile when installing a plugin(try 2)
Ensures that we don't use old state for a plugin that we are installing fresh
This commit is contained in:
parent
2ecf016c80
commit
a096bd547f
2 changed files with 23 additions and 4 deletions
|
|
@ -785,6 +785,20 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
{
|
||||
Log.Debug($"Installing plugin {repoManifest.Name} (testing={useTesting})");
|
||||
|
||||
// If this plugin is in the default profile for whatever reason, delete the state
|
||||
// If it was in multiple profiles and is still, the user uninstalled it and chose to keep it in there,
|
||||
// or the user removed the plugin manually in which case we don't care
|
||||
if (reason == PluginLoadReason.Installer)
|
||||
{
|
||||
// We don't need to apply, it doesn't matter
|
||||
await this.profileManager.DefaultProfile.RemoveAsync(repoManifest.InternalName, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we are doing anything other than a fresh install, not having a workingPluginId is an error that must be fixed
|
||||
Debug.Assert(inheritedWorkingPluginId != null, "inheritedWorkingPluginId != null");
|
||||
}
|
||||
|
||||
// Ensure that we have a testing opt-in for this plugin if we are installing a testing version
|
||||
if (useTesting && this.configuration.PluginTestingOptIns!.All(x => x.InternalName != repoManifest.InternalName))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,17 +200,22 @@ internal class Profile
|
|||
/// </summary>
|
||||
/// <param name="internalName">The internal name of the plugin.</param>
|
||||
/// <param name="apply">Whether or not the current state should immediately be applied.</param>
|
||||
/// <param name="guardrails">
|
||||
/// Throw if certain operations are invalid.
|
||||
/// * Throw if the plugin is not in this profile.
|
||||
/// * If this is the default profile, check if we are in any other, then throw if we aren't.
|
||||
/// </param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public async Task RemoveAsync(string internalName, bool apply = true)
|
||||
public async Task RemoveAsync(string internalName, bool apply = true, bool guardrails = true)
|
||||
{
|
||||
ProfileModelV1.ProfileModelV1Plugin entry;
|
||||
lock (this)
|
||||
{
|
||||
entry = this.modelV1.Plugins.FirstOrDefault(x => x.InternalName == internalName);
|
||||
if (entry == null)
|
||||
if (entry == null && guardrails)
|
||||
throw new ArgumentException($"No plugin \"{internalName}\" in profile \"{this.Guid}\"");
|
||||
|
||||
if (!this.modelV1.Plugins.Remove(entry))
|
||||
if (!this.modelV1.Plugins.Remove(entry) && guardrails)
|
||||
throw new Exception("Couldn't remove plugin from model collection");
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +226,7 @@ internal class Profile
|
|||
{
|
||||
await this.manager.DefaultProfile.AddOrUpdateAsync(internalName, this.IsEnabled && entry.IsEnabled, false);
|
||||
}
|
||||
else
|
||||
else if (guardrails)
|
||||
{
|
||||
throw new Exception("Removed plugin from default profile, but wasn't in any other profile");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue