diff --git a/OverlayPlugin.Updater/Updater.cs b/OverlayPlugin.Updater/Updater.cs index 96465d21e..5b84f03d7 100644 --- a/OverlayPlugin.Updater/Updater.cs +++ b/OverlayPlugin.Updater/Updater.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json.Linq; using Advanced_Combat_Tracker; using Markdig; +using System.Runtime.CompilerServices; namespace RainbowMage.OverlayPlugin.Updater { @@ -25,8 +26,6 @@ public class Updater Version remoteVersion = null; string response; - Registry.Resolve().Log(LogLevel.Debug, "Checking for updates..."); - if (options.actPluginId > 0) { try @@ -116,12 +115,19 @@ public class Updater Registry.Resolve().Log(LogLevel.Error, $"Failed to remove trailers from release notes: {ex}"); } - releaseNotes = Markdown.ToHtml(releaseNotes); + releaseNotes = RenderMarkdown(releaseNotes); return (remoteVersion.CompareTo(options.currentVersion) > 0, remoteVersion, releaseNotes, downloadUrl); }); } + // Move this into its own method to make sure that we only load the Markdown parser if we need it. + [MethodImpl(MethodImplOptions.NoInlining)] + private static string RenderMarkdown(string input) + { + return Markdown.ToHtml(input); + } + public static Task<(bool, Version, string, string)> CheckForManifestUpdate(UpdaterOptions options) { return Task.Run(() => @@ -223,7 +229,7 @@ public static async Task InstallUpdate(string url, UpdaterOptions options) public static async Task RunAutoUpdater(UpdaterOptions options, bool manualCheck = false) { // Only check once per day. - if (!manualCheck && options.lastCheck != null && (DateTime.Now - options.lastCheck).TotalDays < 1) + if (!manualCheck && options.lastCheck != null && (DateTime.Now - options.lastCheck) < options.checkInterval) { return; }