Compare commits

..

No commits in common. "058c086c51e0ca95817cd80f2ae5af894ef8d49b" and "958eb295fb4d4b437da4e5e0a30b64827c395499" have entirely different histories.

3 changed files with 27 additions and 36 deletions

View File

@ -83,24 +83,6 @@ public class DownloadTask : InstallerTaskBase
return Result.FromError("Failed to download Patcher"); return Result.FromError("Failed to download Patcher");
} }
private async Task<IResult> DownloadSptAkiFromMirrors(IProgress<double> progress)
{
// Note that GetOrDownloadFileAsync handles the cached file hash check, so we don't need to check it first
foreach (var mirror in _data.ReleaseInfo.Mirrors)
{
SetStatus("Downloading SPT-AKI", mirror.DownloadUrl, progressStyle: ProgressStyle.Indeterminate);
_data.AkiZipInfo = await DownloadCacheHelper.GetOrDownloadFileAsync("sptaki", mirror.DownloadUrl, progress, mirror.Hash);
if (_data.AkiZipInfo != null)
{
return Result.FromSuccess();
}
}
return Result.FromError("Failed to download spt-aki");
}
public override async Task<IResult> TaskOperation() public override async Task<IResult> TaskOperation()
{ {
var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); }); var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); });
@ -124,6 +106,15 @@ public class DownloadTask : InstallerTaskBase
} }
} }
return await DownloadSptAkiFromMirrors(progress); SetStatus("Downloading SPT-AKI", _data.AkiReleaseDownloadLink, 0);
_data.AkiZipInfo = await DownloadCacheHelper.GetOrDownloadFileAsync("sptaki", _data.AkiReleaseDownloadLink, progress, _data.AkiReleaseHash);
if (_data.AkiZipInfo == null)
{
return Result.FromError("Failed to download spt-aki");
}
return Result.FromSuccess();
} }
} }

View File

@ -4,8 +4,6 @@ using SPTInstaller.Interfaces;
using SPTInstaller.Models; using SPTInstaller.Models;
using System.Threading.Tasks; using System.Threading.Tasks;
using SPTInstaller.Helpers; using SPTInstaller.Helpers;
using Newtonsoft.Json;
using SPTInstaller.Models.Releases;
namespace SPTInstaller.Installer_Tasks; namespace SPTInstaller.Installer_Tasks;
@ -26,25 +24,21 @@ public class ReleaseCheckTask : InstallerTaskBase
SetStatus("Checking SPT Releases", "", null, ProgressStyle.Indeterminate); SetStatus("Checking SPT Releases", "", null, ProgressStyle.Indeterminate);
var progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); }); var akiRepoReleases = await repo.RepoListReleasesAsync("SPT-AKI", "Stable-releases");
var akiReleaseInfoFile = await DownloadCacheHelper.DownloadFileAsync("release.json", "https://spt-releases.modd.in/release.json", progress);
if (akiReleaseInfoFile == null)
{
return Result.FromError("Failed to download release metadata");
}
var akiReleaseInfo = JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(akiReleaseInfoFile.FullName));
SetStatus("Checking for Patches", "", null, ProgressStyle.Indeterminate); SetStatus("Checking for Patches", "", null, ProgressStyle.Indeterminate);
var patchRepoReleases = await repo.RepoListReleasesAsync("SPT-AKI", "Downgrade-Patches"); var patchRepoReleases = await repo.RepoListReleasesAsync("SPT-AKI", "Downgrade-Patches");
var comparePatchToAki = patchRepoReleases?.Find(x => x.Name.Contains(_data.OriginalGameVersion) && x.Name.Contains(akiReleaseInfo.ClientVersion)); var latestAkiRelease = akiRepoReleases.FindAll(x => !x.Prerelease)[0];
var latestAkiVersion = latestAkiRelease.Name.Replace('(', ' ').Replace(')', ' ').Split(' ')[3];
var comparePatchToAki = patchRepoReleases?.Find(x => x.Name.Contains(_data.OriginalGameVersion) && x.Name.Contains(latestAkiVersion));
_data.PatcherMirrorsLink = comparePatchToAki?.Assets[0].BrowserDownloadUrl; _data.PatcherMirrorsLink = comparePatchToAki?.Assets[0].BrowserDownloadUrl;
_data.ReleaseInfo = akiReleaseInfo; _data.AkiReleaseDownloadLink = latestAkiRelease.Assets[0].BrowserDownloadUrl;
_data.AkiReleaseHash = FileHashHelper.GetGiteaReleaseHash(latestAkiRelease);
int IntAkiVersion = int.Parse(akiReleaseInfo.ClientVersion); int IntAkiVersion = int.Parse(latestAkiVersion);
int IntGameVersion = int.Parse(_data.OriginalGameVersion); int IntGameVersion = int.Parse(_data.OriginalGameVersion);
bool patchNeedCheck = false; bool patchNeedCheck = false;
@ -71,7 +65,7 @@ public class ReleaseCheckTask : InstallerTaskBase
_data.PatchNeeded = patchNeedCheck; _data.PatchNeeded = patchNeedCheck;
string status = $"Current Release: {akiReleaseInfo.ClientVersion} - {(_data.PatchNeeded ? "Patch Available" : "No Patch Needed")}"; string status = $"Current Release: {latestAkiVersion} - {(_data.PatchNeeded ? "Patch Available" : "No Patch Needed")}";
SetStatus(null, status); SetStatus(null, status);

View File

@ -1,4 +1,5 @@
using SPTInstaller.Models.Releases; using System.Collections.Generic;
using SPTInstaller.Models.Mirrors;
namespace SPTInstaller.Models; namespace SPTInstaller.Models;
@ -30,9 +31,14 @@ public class InternalData
public FileInfo AkiZipInfo { get; set; } public FileInfo AkiZipInfo { get; set; }
/// <summary> /// <summary>
/// The release information from release.json /// The release download link for SPT-AKI
/// </summary> /// </summary>
public ReleaseInfo ReleaseInfo { get; set; } public string AkiReleaseDownloadLink { get; set; }
/// <summary>
/// The release zip hash
/// </summary>
public string AkiReleaseHash { get; set; } = null;
/// <summary> /// <summary>
/// The release download link for the patcher mirror list /// The release download link for the patcher mirror list