Skip to content

Commit 770eec5

Browse files
author
Peter de Vroom
committed
Use System.Version to compare versions
Add error checking
1 parent 4fcc12d commit 770eec5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,12 @@ private static string GetContainingFolderPathAfterUnzip(string unzippedParentFol
550550
private static bool SameOrLesserPluginVersionExists(string metadataPath)
551551
{
552552
var newMetadata = JsonSerializer.Deserialize<PluginMetadata>(File.ReadAllText(metadataPath));
553+
if (!Version.TryParse(newMetadata.Version, out var newVersion))
554+
throw new InvalidOperationException($"A plugin with the same ID and version already exists, or the version is greater than this downloaded plugin {plugin.Name}");
555+
553556
return AllPlugins.Any(x => x.Metadata.ID == newMetadata.ID
554-
&& newMetadata.Version.CompareTo(x.Metadata.Version) <= 0);
557+
&& Version.TryParse(x.Metadata.Version, out var version)
558+
&& newVersion <= version);
555559
}
556560

557561
#region Public functions

0 commit comments

Comments
 (0)