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> <PackageIcon>icon.ico</PackageIcon>
<ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon> <ApplicationIcon>Assets\spt_installer.ico</ApplicationIcon>
<Configurations>Debug;Release;TEST</Configurations> <Configurations>Debug;Release;TEST</Configurations>
<AssemblyVersion>2.95</AssemblyVersion> <AssemblyVersion>2.96</AssemblyVersion>
<FileVersion>2.95</FileVersion> <FileVersion>2.96</FileVersion>
<Company>SPT</Company> <Company>SPT</Company>
</PropertyGroup> </PropertyGroup>

View File

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