Skip to content

Commit b02a5a2

Browse files
committed
Refactor plugin min version check and improve logging
Refactored the plugin minimum app version check to use Version.TryParse instead of try-catch with Version.Parse, preventing exceptions on invalid input. Improved error handling by logging parse failures as errors and version mismatches as info, making the logic clearer and more robust.
1 parent b1b18ee commit b02a5a2

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,18 +1082,17 @@ internal static bool IsMinimumAppVersionSatisfied(string pluginName, string mini
10821082

10831083
var appVersion = Version.Parse(Constant.Version);
10841084

1085-
try
1086-
{
1087-
if (appVersion >= Version.Parse(minimumAppVersion))
1088-
return true;
1089-
}
1090-
catch (Exception e)
1085+
if (!Version.TryParse(minimumAppVersion, out var minimumVersion))
10911086
{
1092-
PublicApi.Instance.LogException(ClassName, $"Failed to parse the minimum app version {minimumAppVersion} for plugin {pluginName}. "
1093-
+ "Plugin excluded from manifest", e);
1094-
return false;
1087+
PublicApi.Instance.LogError(ClassName,
1088+
$"Failed to parse the minimum app version {minimumAppVersion} for plugin {pluginName}. "
1089+
+ "Plugin excluded from manifest");
1090+
return false; // If the minimum app version specified in plugin.json is invalid, we assume it is not satisfied
10951091
}
10961092

1093+
if (appVersion >= minimumVersion)
1094+
return true;
1095+
10971096
PublicApi.Instance.LogInfo(ClassName, $"Plugin {pluginName} requires minimum Flow Launcher version {minimumAppVersion}, "
10981097
+ $"but current version is {Constant.Version}. Plugin excluded from manifest.");
10991098

0 commit comments

Comments
 (0)