mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
pm: don't install updates twice, don't globally lock the plugin list while updates are installing
This commit is contained in:
parent
c028fecf62
commit
df51fc17e6
4 changed files with 41 additions and 12 deletions
|
|
@ -119,6 +119,16 @@ internal class AutoUpdateManager : IServiceType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsAutoUpdateComplete { get; private set; }
|
public bool IsAutoUpdateComplete { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the time of the next scheduled update check.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? NextUpdateCheckTime => this.nextUpdateCheckTime;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the time the auto-update was unblocked.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? UnblockedSince => this.unblockedSince;
|
||||||
|
|
||||||
private static UpdateListingRestriction DecideUpdateListingRestriction(AutoUpdateBehavior behavior)
|
private static UpdateListingRestriction DecideUpdateListingRestriction(AutoUpdateBehavior behavior)
|
||||||
{
|
{
|
||||||
return behavior switch
|
return behavior switch
|
||||||
|
|
|
||||||
|
|
@ -995,20 +995,16 @@ internal class PluginManager : IInternalDisposableService
|
||||||
var totalPlugins = toUpdate.Count;
|
var totalPlugins = toUpdate.Count;
|
||||||
var processedPlugins = 0;
|
var processedPlugins = 0;
|
||||||
|
|
||||||
// Prevent collection was modified errors
|
foreach (var plugin in toUpdate)
|
||||||
lock (this.pluginListLock)
|
|
||||||
{
|
{
|
||||||
foreach (var plugin in toUpdate)
|
// Can't update that!
|
||||||
{
|
if (plugin.InstalledPlugin.IsDev)
|
||||||
// Can't update that!
|
continue;
|
||||||
if (plugin.InstalledPlugin.IsDev)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (plugin.InstalledPlugin.Manifest.ScheduledForDeletion)
|
if (plugin.InstalledPlugin.Manifest.ScheduledForDeletion)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
updateTasks.Add(UpdateSinglePluginWithProgressAsync(plugin));
|
updateTasks.Add(UpdateSinglePluginWithProgressAsync(plugin));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var updatedList = await Task.WhenAll(updateTasks);
|
var updatedList = await Task.WhenAll(updateTasks);
|
||||||
|
|
@ -1065,6 +1061,18 @@ internal class PluginManager : IInternalDisposableService
|
||||||
Status = PluginUpdateStatus.StatusKind.Success,
|
Status = PluginUpdateStatus.StatusKind.Success,
|
||||||
HasChangelog = !metadata.UpdateManifest.Changelog.IsNullOrWhitespace(),
|
HasChangelog = !metadata.UpdateManifest.Changelog.IsNullOrWhitespace(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check if this plugin is already up to date (=> AvailablePluginUpdate was stale)
|
||||||
|
lock (this.installedPluginsList)
|
||||||
|
{
|
||||||
|
var matchedPlugin = this.installedPluginsList.FirstOrDefault(x => x.EffectiveWorkingPluginId == workingPluginId);
|
||||||
|
if (matchedPlugin?.EffectiveVersion == metadata.EffectiveVersion)
|
||||||
|
{
|
||||||
|
Log.Information("Plugin {Name} is already up to date", plugin.Manifest.Name);
|
||||||
|
updateStatus.Status = PluginUpdateStatus.StatusKind.AlreadyUpToDate;
|
||||||
|
return updateStatus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!dryRun)
|
if (!dryRun)
|
||||||
{
|
{
|
||||||
|
|
@ -1457,7 +1465,7 @@ internal class PluginManager : IInternalDisposableService
|
||||||
// ignored, since the plugin may be loaded already
|
// ignored, since the plugin may be loaded already
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.Debug($"Extracting to {outputDir}");
|
Log.Debug("Extracting to {OutputDir}", outputDir);
|
||||||
|
|
||||||
using (var archive = new ZipArchive(zipStream))
|
using (var archive = new ZipArchive(zipStream))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,10 @@ internal record AvailablePluginUpdate
|
||||||
/// Gets a value indicating whether the update should use the testing URL.
|
/// Gets a value indicating whether the update should use the testing URL.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseTesting { get; init; }
|
public bool UseTesting { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the effective version to use for the update.
|
||||||
|
/// </summary>
|
||||||
|
public Version EffectiveVersion => (this.UseTesting ? this.UpdateManifest.TestingAssemblyVersion : this.UpdateManifest.AssemblyVersion)
|
||||||
|
?? throw new Exception("Update manifest does not contain a valid version.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,11 @@ internal class PluginUpdateStatus
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FailedLoad,
|
FailedLoad,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The updated plugin is already up to date.
|
||||||
|
/// </summary>
|
||||||
|
AlreadyUpToDate,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The update succeeded.
|
/// The update succeeded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue