Browse Source

Update update precedence checking to support metadata

pull/55/head
Ionite 1 year ago
parent
commit
e7b98cfb4c
No known key found for this signature in database
  1. 19
      StabilityMatrix.Core/Updater/UpdateHelper.cs

19
StabilityMatrix.Core/Updater/UpdateHelper.cs

@ -123,13 +123,30 @@ public class UpdateHelper : IUpdateHelper
}
logger.LogInformation("UpdateInfo signature verified");
if (updateInfo.Version.ComparePrecedenceTo(Compat.AppVersion) > 0)
var order = updateInfo.Version.ComparePrecedenceTo(Compat.AppVersion);
if (order > 0)
{
// Newer version available
logger.LogInformation("Update available {AppVer} -> {UpdateVer}",
Compat.AppVersion, updateInfo.Version);
EventManager.Instance.OnUpdateAvailable(updateInfo);
return;
}
if (order == 0)
{
// Same version available, check if we both have commit hash metadata
var updateHash = updateInfo.Version.Metadata;
var appHash = Compat.AppVersion.Metadata;
// If different, we can update
if (updateHash != appHash)
{
logger.LogInformation("Update available {AppVer} -> {UpdateVer}",
Compat.AppVersion, updateInfo.Version);
EventManager.Instance.OnUpdateAvailable(updateInfo);
return;
}
}
logger.LogInformation("No update available");
}

Loading…
Cancel
Save