mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
feat: assign every installation of a plugin a unique id, to be used to differentiate between them in the future(api9+)
This commit is contained in:
parent
1b46bbac87
commit
4dc43b7ed3
5 changed files with 42 additions and 3 deletions
|
|
@ -2186,6 +2186,14 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
ImGuiHelpers.SafeTextWrapped(manifest.Description);
|
||||
}
|
||||
|
||||
// Working Plugin ID
|
||||
if (this.hasDevPlugins)
|
||||
{
|
||||
ImGuiHelpers.ScaledDummy(3);
|
||||
ImGui.TextColored(ImGuiColors.DalamudGrey, $"WorkingPluginId: {manifest.WorkingPluginId}");
|
||||
ImGuiHelpers.ScaledDummy(3);
|
||||
}
|
||||
|
||||
// Available commands (if loaded)
|
||||
if (plugin.IsLoaded)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -763,8 +763,9 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
/// <param name="repoManifest">The plugin definition.</param>
|
||||
/// <param name="useTesting">If the testing version should be used.</param>
|
||||
/// <param name="reason">The reason this plugin was loaded.</param>
|
||||
/// <param name="inheritedWorkingPluginId">WorkingPluginId this plugin should inherit.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
public async Task<LocalPlugin> InstallPluginAsync(RemotePluginManifest repoManifest, bool useTesting, PluginLoadReason reason)
|
||||
public async Task<LocalPlugin> InstallPluginAsync(RemotePluginManifest repoManifest, bool useTesting, PluginLoadReason reason, Guid? inheritedWorkingPluginId = null)
|
||||
{
|
||||
Log.Debug($"Installing plugin {repoManifest.Name} (testing={useTesting})");
|
||||
|
||||
|
|
@ -851,6 +852,9 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
// Reload as a local manifest, add some attributes, and save again.
|
||||
var manifest = LocalPluginManifest.Load(manifestFile);
|
||||
|
||||
if (manifest == null)
|
||||
throw new Exception("Plugin had no valid manifest");
|
||||
|
||||
if (manifest.InternalName != repoManifest.InternalName)
|
||||
{
|
||||
Directory.Delete(outputDir.FullName, true);
|
||||
|
|
@ -858,6 +862,11 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
$"Distributed internal name does not match repo internal name: {manifest.InternalName} - {repoManifest.InternalName}");
|
||||
}
|
||||
|
||||
if (manifest.WorkingPluginId != Guid.Empty)
|
||||
throw new Exception("Plugin shall not specify a WorkingPluginId");
|
||||
|
||||
manifest.WorkingPluginId = inheritedWorkingPluginId ?? Guid.NewGuid();
|
||||
|
||||
if (useTesting)
|
||||
{
|
||||
manifest.Testing = true;
|
||||
|
|
@ -1040,6 +1049,10 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
{
|
||||
var plugin = metadata.InstalledPlugin;
|
||||
|
||||
var workingPluginId = metadata.InstalledPlugin.Manifest.WorkingPluginId;
|
||||
if (workingPluginId == Guid.Empty)
|
||||
throw new Exception("Existing plugin had no WorkingPluginId");
|
||||
|
||||
var updateStatus = new PluginUpdateStatus
|
||||
{
|
||||
InternalName = plugin.Manifest.InternalName,
|
||||
|
|
@ -1099,7 +1112,7 @@ internal partial class PluginManager : IDisposable, IServiceType
|
|||
|
||||
try
|
||||
{
|
||||
await this.InstallPluginAsync(metadata.UpdateManifest, metadata.UseTesting, PluginLoadReason.Update);
|
||||
await this.InstallPluginAsync(metadata.UpdateManifest, metadata.UseTesting, PluginLoadReason.Update, workingPluginId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,6 +158,14 @@ internal class LocalPlugin : IDisposable
|
|||
needsSaveDueToLegacyFiles = true;
|
||||
}
|
||||
|
||||
// Create an installation instance ID for this plugin, if it doesn't have one yet
|
||||
if (this.manifest.WorkingPluginId == Guid.Empty)
|
||||
{
|
||||
this.manifest.WorkingPluginId = Guid.NewGuid();
|
||||
|
||||
needsSaveDueToLegacyFiles = true;
|
||||
}
|
||||
|
||||
var pluginManager = Service<PluginManager>.Get();
|
||||
this.IsBanned = pluginManager.IsManifestBanned(this.manifest) && !this.IsDev;
|
||||
this.BanReason = pluginManager.GetBanReason(this.manifest);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
namespace Dalamud.Plugin.Internal.Types.Manifest;
|
||||
using System;
|
||||
|
||||
namespace Dalamud.Plugin.Internal.Types.Manifest;
|
||||
|
||||
/// <summary>
|
||||
/// Public interface for the local plugin manifest.
|
||||
|
|
@ -16,4 +18,9 @@ public interface ILocalPluginManifest : IPluginManifest
|
|||
/// Gets a value indicating whether the plugin should be deleted during the next cleanup.
|
||||
/// </summary>
|
||||
public bool ScheduledForDeletion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an ID uniquely identifying this specific installation of a plugin.
|
||||
/// </summary>
|
||||
public Guid WorkingPluginId { get; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ internal record LocalPluginManifest : PluginManifest, ILocalPluginManifest
|
|||
/// <inheritdoc/>
|
||||
public string InstalledFromUrl { get; set; } = string.Empty;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Guid WorkingPluginId { get; set; } = Guid.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this manifest is associated with a plugin that was installed from a third party
|
||||
/// repo. Unless the manifest has been manually modified, this is determined by the InstalledFromUrl being null.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue