Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ static PluginManager()
/// <param name="settings"></param>
public static void LoadPlugins(PluginsSettings settings)
{
if (PluginUpgrader.ForceUpgradeRequired(settings))
PluginUpgrader.ForceUpgrade(settings);

_metadatas = PluginConfig.Parse(Directories);
Settings = settings;
Settings.UpdatePluginSettings(_metadatas);
Expand Down
41 changes: 41 additions & 0 deletions Flow.Launcher.Core/Plugin/PluginUpgrader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Flow.Launcher.Core.Plugin
{
public static class PluginUpgrader
{
/// <summary>
/// Indicates these plugins need to have version greater than currently recorded
/// </summary>
private static readonly Dictionary<string, PluginVersion> PluginsUpgradeRequiredVersion = new()
{
{ "D2D2C23B084D411DB66FE0C79D6C2A6E", new PluginVersion { ForceUpgradeRequiredVersion = "1.4.9" } }
};

internal static void ForceUpgrade(PluginsSettings settings)
{
// if new version is added for PluginVersion.NewVersionDownloadUrl=> remove older plugin, download & extract
// if PluginVersion.NewVersionDownloadUrl does not contain new version url, disable plugin and prompt to notify user
}

internal static bool ForceUpgradeRequired(PluginsSettings settings)
{
return
settings.Plugins
.Any(t1 => PluginsUpgradeRequiredVersion
.Any(x => x.Key == t1.Key && x.Value.ForceUpgradeRequiredVersion == t1.Value.Version));
}
}

internal class PluginVersion
{
internal string ForceUpgradeRequiredVersion;

internal string NewVersionDownloadUrl = string.Empty;
}
}