mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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.
This commit is contained in:
parent
b1b18ee215
commit
b02a5a265d
1 changed files with 8 additions and 9 deletions
|
|
@ -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.");
|
||||
|
|
|
|||
Loading…
Reference in a new issue