From 770eec529658c720f35d19359ba739a1df6f9047 Mon Sep 17 00:00:00 2001 From: Peter de Vroom Date: Mon, 7 Jul 2025 13:50:07 +1000 Subject: [PATCH 1/2] Use System.Version to compare versions Add error checking --- Flow.Launcher.Core/Plugin/PluginManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 444a44a0a81..2255290622c 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -550,8 +550,12 @@ private static string GetContainingFolderPathAfterUnzip(string unzippedParentFol private static bool SameOrLesserPluginVersionExists(string metadataPath) { var newMetadata = JsonSerializer.Deserialize(File.ReadAllText(metadataPath)); + if (!Version.TryParse(newMetadata.Version, out var newVersion)) + throw new InvalidOperationException($"A plugin with the same ID and version already exists, or the version is greater than this downloaded plugin {plugin.Name}"); + return AllPlugins.Any(x => x.Metadata.ID == newMetadata.ID - && newMetadata.Version.CompareTo(x.Metadata.Version) <= 0); + && Version.TryParse(x.Metadata.Version, out var version) + && newVersion <= version); } #region Public functions From 988a3bc09e670183fd5af18e9f89f50cd60e2bfc Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 7 Jul 2025 14:00:07 +0800 Subject: [PATCH 2/2] Do not throw exception & Fix blank lines --- Flow.Launcher.Core/Plugin/PluginManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 2255290622c..03ebfc31c2c 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -550,8 +550,9 @@ private static string GetContainingFolderPathAfterUnzip(string unzippedParentFol private static bool SameOrLesserPluginVersionExists(string metadataPath) { var newMetadata = JsonSerializer.Deserialize(File.ReadAllText(metadataPath)); + if (!Version.TryParse(newMetadata.Version, out var newVersion)) - throw new InvalidOperationException($"A plugin with the same ID and version already exists, or the version is greater than this downloaded plugin {plugin.Name}"); + return true; // If version is not valid, we assume it is lesser than any existing version return AllPlugins.Any(x => x.Metadata.ID == newMetadata.ID && Version.TryParse(x.Metadata.Version, out var version)