From 39bc1fe719c08929c74042c190e4afaec8197b61 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Mon, 18 Jul 2016 10:51:25 +0200 Subject: [PATCH] Initialize AutoUpdatesTimer earlier This fixes the potential issue of not initializing timer if first version check fails due to e.g. network failure --- ArchiSteamFarm/Program.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 2aa03554b..c39e2024d 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -105,6 +105,17 @@ namespace ArchiSteamFarm { return; } + if ((AutoUpdatesTimer == null) && GlobalConfig.AutoUpdates) { + AutoUpdatesTimer = new Timer( + async e => await CheckForUpdate().ConfigureAwait(false), + null, + TimeSpan.FromDays(1), // Delay + TimeSpan.FromDays(1) // Period + ); + + Logging.LogGenericInfo("ASF will automatically check for new versions every 24 hours"); + } + string releaseURL = GithubReleaseURL; if (GlobalConfig.UpdateChannel == GlobalConfig.EUpdateChannel.Stable) { releaseURL += "/latest"; @@ -153,19 +164,6 @@ namespace ArchiSteamFarm { Logging.LogGenericInfo("Local version: " + Version + " | Remote version: " + newVersion); if (Version.CompareTo(newVersion) >= 0) { // If local version is the same or newer than remote version - if ((AutoUpdatesTimer != null) || !GlobalConfig.AutoUpdates) { - return; - } - - Logging.LogGenericInfo("ASF will automatically check for new versions every 24 hours"); - - AutoUpdatesTimer = new Timer( - async e => await CheckForUpdate().ConfigureAwait(false), - null, - TimeSpan.FromDays(1), // Delay - TimeSpan.FromDays(1) // Period - ); - return; }