Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,26 @@ private async Task<ShouldUpdateResponse> 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)
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) return false;
if (timeSinceLastCheck.TotalHours < 8)
{
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;
}

Expand Down
Loading