Skip to content

Commit 3abafc0

Browse files
author
Peter de Vroom
committed
Add error checking
1 parent 24b87aa commit 3abafc0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +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-
var newVersion = new Version(newMetadata.Version);
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+
554556
return AllPlugins.Any(x => x.Metadata.ID == newMetadata.ID
555-
&& newVersion <= (new Version(x.Metadata.Version)));
557+
&& Version.TryParse(x.Metadata.Version, out var version)
558+
&& newVersion <= version);
556559
}
557560

558561
#region Public functions

0 commit comments

Comments
 (0)