Skip to content

Commit

Permalink
Fixed updater issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ngld committed Jan 15, 2020
1 parent bfe9a1e commit d3b09d9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions OverlayPlugin.Updater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Newtonsoft.Json.Linq;
using Advanced_Combat_Tracker;
using Markdig;
using System.Runtime.CompilerServices;

namespace RainbowMage.OverlayPlugin.Updater
{
Expand All @@ -25,8 +26,6 @@ public class Updater
Version remoteVersion = null;
string response;

Registry.Resolve<ILogger>().Log(LogLevel.Debug, "Checking for updates...");

if (options.actPluginId > 0)
{
try
Expand Down Expand Up @@ -116,12 +115,19 @@ public class Updater
Registry.Resolve<ILogger>().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(() =>
Expand Down Expand Up @@ -223,7 +229,7 @@ public static async Task<bool> 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;
}
Expand Down

0 comments on commit d3b09d9

Please sign in to comment.