From b02a5a265d0442dd8b06374e75b7b4d612408224 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Fri, 27 Feb 2026 18:48:59 +0800 Subject: [PATCH] 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. --- Flow.Launcher.Core/Plugin/PluginManager.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index e4972453f..f78b59360 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -1082,17 +1082,16 @@ namespace Flow.Launcher.Core.Plugin var appVersion = Version.Parse(Constant.Version); - try + if (!Version.TryParse(minimumAppVersion, out var minimumVersion)) { - if (appVersion >= Version.Parse(minimumAppVersion)) + PublicApi.Instance.LogError(ClassName, + $"Failed to parse the minimum app version {minimumAppVersion} for plugin {pluginName}. " + + "Plugin excluded from manifest"); + return false; // If the minimum app version specified in plugin.json is invalid, we assume it is not satisfied + } + + if (appVersion >= minimumVersion) return true; - } - catch (Exception e) - { - PublicApi.Instance.LogException(ClassName, $"Failed to parse the minimum app version {minimumAppVersion} for plugin {pluginName}. " - + "Plugin excluded from manifest", e); - return false; - } PublicApi.Instance.LogInfo(ClassName, $"Plugin {pluginName} requires minimum Flow Launcher version {minimumAppVersion}, " + $"but current version is {Constant.Version}. Plugin excluded from manifest.");