Merge pull request #410 from goaaats/fix_update

This commit is contained in:
goaaats 2021-07-15 15:13:16 +02:00 committed by GitHub
commit 7ac977cb46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -679,7 +679,7 @@ namespace Dalamud.Interface.Internal.Windows
this.DrawVisitRepoUrlButton(plugin.Manifest.RepoUrl); this.DrawVisitRepoUrlButton(plugin.Manifest.RepoUrl);
if (availablePluginUpdate != default) if (availablePluginUpdate != default)
this.DrawUpdateSinglePluginButton(plugin, availablePluginUpdate); this.DrawUpdateSinglePluginButton(availablePluginUpdate);
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextColored(ImGuiColors.DalamudGrey3, $" v{plugin.Manifest.AssemblyVersion}"); ImGui.TextColored(ImGuiColors.DalamudGrey3, $" v{plugin.Manifest.AssemblyVersion}");
@ -781,7 +781,7 @@ namespace Dalamud.Interface.Internal.Windows
} }
} }
private void DrawUpdateSinglePluginButton(LocalPlugin plugin, AvailablePluginUpdate update) private void DrawUpdateSinglePluginButton(AvailablePluginUpdate update)
{ {
ImGui.SameLine(); ImGui.SameLine();
@ -800,7 +800,7 @@ namespace Dalamud.Interface.Internal.Windows
if (!task.Result.WasUpdated) if (!task.Result.WasUpdated)
{ {
ShowErrorModal(errorMessage); this.ShowErrorModal(errorMessage);
} }
}); });
} }

View file

@ -800,15 +800,24 @@ namespace Dalamud.Plugin.Internal
{ {
var updatablePlugins = new List<AvailablePluginUpdate>(); var updatablePlugins = new List<AvailablePluginUpdate>();
if (!this.ReposReady)
throw new Exception("Plugin updates can only be detected when repos are available.");
// Collect all outdated and current plugin manifests
var remoteManifests =
this.Repos.SelectMany(x => x.PluginMaster).Where(x => x.DalamudApiLevel <= DalamudApiLevel).ToList();
for (var i = 0; i < this.installedPlugins.Count; i++) for (var i = 0; i < this.installedPlugins.Count; i++)
{ {
var plugin = this.installedPlugins[i]; var plugin = this.installedPlugins[i];
Log.Debug($"Checking plugin updates for {plugin.Manifest.InternalName}");
var installedVersion = plugin.IsTesting var installedVersion = plugin.IsTesting
? plugin.Manifest.TestingAssemblyVersion ? plugin.Manifest.TestingAssemblyVersion
: plugin.Manifest.AssemblyVersion; : plugin.Manifest.AssemblyVersion;
var updates = this.availablePlugins var updates = remoteManifests
.Where(remoteManifest => plugin.Manifest.InternalName == remoteManifest.InternalName) .Where(remoteManifest => plugin.Manifest.InternalName == remoteManifest.InternalName)
.Select(remoteManifest => .Select(remoteManifest =>
{ {
@ -818,6 +827,8 @@ namespace Dalamud.Plugin.Internal
: remoteManifest.AssemblyVersion; : remoteManifest.AssemblyVersion;
var isUpdate = candidateVersion > installedVersion; var isUpdate = candidateVersion > installedVersion;
Log.Debug($" => {remoteManifest.InternalName} from {remoteManifest.SourceRepo.PluginMasterUrl} - candidate: {candidateVersion} installed: {installedVersion}");
return (isUpdate, useTesting, candidateVersion, remoteManifest); return (isUpdate, useTesting, candidateVersion, remoteManifest);
}) })
.Where(tpl => tpl.isUpdate) .Where(tpl => tpl.isUpdate)