private static async Task <bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false) { try { splashScreenWindow.StartSkipTimer(); var updateInfo = await mgr.CheckForUpdate(ignoreDelta); if (!updateInfo.ReleasesToApply.Any()) { return(false); } if (updateInfo.ReleasesToApply.LastOrDefault()?.Version <= mgr.CurrentlyInstalledVersion()) { return(false); } await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating); await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing); await mgr.CreateUninstallerRegistryEntry(); return(true); } catch (Exception) { if (!ignoreDelta) { return(await SquirrelUpdate(splashScreenWindow, mgr, true)); } return(false); } }
private static async Task <bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false) { try { Log.Info($"Checking for updates (ignoreDelta={ignoreDelta})"); splashScreenWindow.StartSkipTimer(); var updateInfo = await mgr.CheckForUpdate(ignoreDelta); if (!updateInfo.ReleasesToApply.Any()) { Log.Info("No new updated available"); return(false); } var latest = updateInfo.ReleasesToApply.LastOrDefault()?.Version; var current = mgr.CurrentlyInstalledVersion(); if (latest <= current) { Log.Info($"Installed version ({current}) is greater than latest release found ({latest}). Not downloading updates."); return(false); } if (IsRevisionIncrement(current?.Version, latest?.Version)) { Log.Info($"Latest update ({latest}) is revision increment. Updating in background."); splashScreenWindow.SkipUpdate = true; } Log.Info($"Downloading {updateInfo.ReleasesToApply.Count} {(ignoreDelta ? "" : "delta ")}releases, latest={latest?.Version}"); await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating); Log.Info("Applying releases"); await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing); await mgr.CreateUninstallerRegistryEntry(); Log.Info("Done"); return(true); } catch (Exception ex) { if (ignoreDelta) { return(false); } if (ex is Win32Exception) { Log.Info("Not able to apply deltas, downloading full release"); } return(await SquirrelUpdate(splashScreenWindow, mgr, true)); } }