From e5aa16f5cffd4128943c1dbb8288bdf12613630a Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Mon, 24 Mar 2025 12:19:17 +0100 Subject: [PATCH 1/4] Add logging to ShouldCheckForUpdate --- .../FwLiteMaui/Platforms/Windows/AppUpdateService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs index 3e6730e7b5..49cdea41a1 100644 --- a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs +++ b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs @@ -202,17 +202,26 @@ private async Task ShouldUpdate() private bool ShouldCheckForUpdate() { if (ValidPositiveEnvVarValues.Contains(Environment.GetEnvironmentVariable(ForceUpdateCheckEnvVar) ?? "")) + { + logger.LogInformation("Should check for update based on env var {EnvVar}", PreventUpdateCheckEnvVar); return true; + } var lastChecked = preferences.Get(LastUpdateCheck, DateTime.MinValue); var timeSinceLastCheck = DateTime.UtcNow - lastChecked; //if last checked is in the future (should never happen), then we want to reset the time and check again if (timeSinceLastCheck.Hours < -1) { preferences.Set(LastUpdateCheck, DateTime.UtcNow); + logger.LogInformation("Should check for update, because last check was in the future: {LastCheck}", lastChecked); return true; } - if (timeSinceLastCheck.Hours < 20) return false; + if (timeSinceLastCheck.Hours < 20) + { + logger.LogInformation("Should not check for update, because last check was too recent: {LastCheck}", lastChecked); + return false; + } preferences.Set(LastUpdateCheck, DateTime.UtcNow); + logger.LogInformation("Should check for update based on last check time: {LastCheck}", lastChecked); return true; } From fc6654a6ec8d457cc946bc6359a6bd3d19ff5f51 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Mon, 24 Mar 2025 12:19:43 +0100 Subject: [PATCH 2/4] Use TotalHours instead of Hours or UpdateChecking --- .../FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs index 49cdea41a1..0b10d69948 100644 --- a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs +++ b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs @@ -209,13 +209,13 @@ private bool ShouldCheckForUpdate() var lastChecked = preferences.Get(LastUpdateCheck, DateTime.MinValue); var timeSinceLastCheck = DateTime.UtcNow - lastChecked; //if last checked is in the future (should never happen), then we want to reset the time and check again - if (timeSinceLastCheck.Hours < -1) + if (timeSinceLastCheck.TotalHours < -1) { preferences.Set(LastUpdateCheck, DateTime.UtcNow); logger.LogInformation("Should check for update, because last check was in the future: {LastCheck}", lastChecked); return true; } - if (timeSinceLastCheck.Hours < 20) + if (timeSinceLastCheck.TotalHours < 20) { logger.LogInformation("Should not check for update, because last check was too recent: {LastCheck}", lastChecked); return false; From 5f72482c00b4a12981f81847c5e906d51795124b Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Mon, 24 Mar 2025 12:20:01 +0100 Subject: [PATCH 3/4] Decrease update check to 8 hours --- backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs index 0b10d69948..917504939b 100644 --- a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs +++ b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs @@ -215,7 +215,7 @@ private bool ShouldCheckForUpdate() logger.LogInformation("Should check for update, because last check was in the future: {LastCheck}", lastChecked); return true; } - if (timeSinceLastCheck.TotalHours < 20) + if (timeSinceLastCheck.TotalHours < 8) { logger.LogInformation("Should not check for update, because last check was too recent: {LastCheck}", lastChecked); return false; From 3656160f900c94c44a20e864a85519ce685d5ac6 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Mon, 24 Mar 2025 12:27:12 +0100 Subject: [PATCH 4/4] Reference correct env-var in log --- backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs index 917504939b..6931fce33c 100644 --- a/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs +++ b/backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs @@ -203,7 +203,7 @@ private bool ShouldCheckForUpdate() { if (ValidPositiveEnvVarValues.Contains(Environment.GetEnvironmentVariable(ForceUpdateCheckEnvVar) ?? "")) { - logger.LogInformation("Should check for update based on env var {EnvVar}", PreventUpdateCheckEnvVar); + logger.LogInformation("Should check for update based on env var {EnvVar}", ForceUpdateCheckEnvVar); return true; } var lastChecked = preferences.Get(LastUpdateCheck, DateTime.MinValue);