mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-26 13:39:41 +00:00
fix self-updater version compare
This commit is contained in:
@@ -188,17 +188,35 @@ namespace AutopilotMonitor.Agent
|
||||
|
||||
/// <summary>
|
||||
/// Compares two version strings. Returns true if latest is newer than current.
|
||||
/// Strips SemVer suffixes (+metadata, -prerelease) before parsing because
|
||||
/// System.Version cannot handle them (e.g. "1.0.386+b7f8d3c..." would fail).
|
||||
/// </summary>
|
||||
private static bool IsNewerVersion(string current, string latest)
|
||||
{
|
||||
if (!Version.TryParse(current, out var currentVer))
|
||||
if (!Version.TryParse(StripVersionSuffix(current), out var currentVer))
|
||||
return false;
|
||||
if (!Version.TryParse(latest, out var latestVer))
|
||||
if (!Version.TryParse(StripVersionSuffix(latest), out var latestVer))
|
||||
return false;
|
||||
|
||||
return latestVer > currentVer;
|
||||
}
|
||||
|
||||
private static string StripVersionSuffix(string version)
|
||||
{
|
||||
if (string.IsNullOrEmpty(version))
|
||||
return version;
|
||||
|
||||
var plusIndex = version.IndexOf('+');
|
||||
if (plusIndex >= 0)
|
||||
version = version.Substring(0, plusIndex);
|
||||
|
||||
var dashIndex = version.IndexOf('-');
|
||||
if (dashIndex >= 0)
|
||||
version = version.Substring(0, dashIndex);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Downloads the agent ZIP to a temp path. Returns false on failure.
|
||||
/// </summary>
|
||||
|
||||
@@ -1 +1 @@
|
||||
388
|
||||
390
|
||||
|
||||
Reference in New Issue
Block a user