0
0
mirror of https://github.com/sp-tarkov/installer.git synced 2025-02-12 13:50:45 -05:00

add catch / retry to inital release json check

This commit is contained in:
IsWaffle 2025-01-03 16:53:51 -05:00
parent 113ff42ed8
commit aa31c970ba
2 changed files with 32 additions and 17 deletions

View File

@ -10,8 +10,8 @@
<PackageIcon>icon.ico</PackageIcon>
<ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon>
<Configurations>Debug;Release;TEST</Configurations>
<AssemblyVersion>2.95</AssemblyVersion>
<FileVersion>2.95</FileVersion>
<AssemblyVersion>2.96</AssemblyVersion>
<FileVersion>2.96</FileVersion>
<Company>SPT</Company>
</PropertyGroup>

View File

@ -244,29 +244,44 @@ public class PreChecksViewModel : ViewModelBase
InstallButtonCheckState = StatusSpinner.SpinnerState.Running;
var progress = new Progress<double>((d) => { });
var SPTReleaseInfoFile =
await DownloadCacheHelper.GetOrDownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl,
progress, DownloadCacheHelper.SuggestedTtl);
if (SPTReleaseInfoFile == null)
ReleaseInfo? sptReleaseInfo = null;
var retries = 1;
while (retries >= 0)
{
InstallButtonText = "Could not get SPT release metadata";
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
return;
retries--;
try
{
var sptReleaseInfoFile =
await DownloadCacheHelper.GetOrDownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl,
progress, DownloadCacheHelper.SuggestedTtl);
if (sptReleaseInfoFile == null)
{
InstallButtonText = "Could not get SPT release metadata";
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
return;
}
sptReleaseInfo =
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(sptReleaseInfoFile.FullName));
}
catch (Exception)
{
DownloadCacheHelper.ClearMetadataCache();
}
}
var SPTReleaseInfo =
JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(SPTReleaseInfoFile.FullName));
if (SPTReleaseInfo == null)
if (sptReleaseInfo == null)
{
InstallButtonText = "Could not parse latest SPT release";
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
return;
}
InstallButtonText = $"Start Install: SPT v{SPTReleaseInfo.SPTVersion}";
InstallButtonText = $"Start Install: SPT v{sptReleaseInfo.SPTVersion}";
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
AllowDetailsButton = true;