Merge pull request 'Switch the precheck to use the release.json method of version fetching' (#77) from DrakiaXYZ/SPT-AKI-Installer:fix-release-fetch into master
Reviewed-on: CWX/SPT-AKI-Installer#77
This commit is contained in:
commit
1c595fc239
@ -10,6 +10,7 @@ public static class DownloadCacheHelper
|
|||||||
private static HttpClient _httpClient = new() { Timeout = TimeSpan.FromHours(1) };
|
private static HttpClient _httpClient = new() { Timeout = TimeSpan.FromHours(1) };
|
||||||
|
|
||||||
public static string CachePath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "spt-installer/cache");
|
public static string CachePath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "spt-installer/cache");
|
||||||
|
public static string ReleaseMirrorUrl = "https://spt-releases.modd.in/release.json";
|
||||||
|
|
||||||
public static string GetCacheSizeText()
|
public static string GetCacheSizeText()
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ using SPTInstaller.Models;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using SPTInstaller.Helpers;
|
using SPTInstaller.Helpers;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SPTInstaller.Models.Releases;
|
using SPTInstaller.Models.ReleaseInfo;
|
||||||
|
|
||||||
namespace SPTInstaller.Installer_Tasks;
|
namespace SPTInstaller.Installer_Tasks;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ 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 progress = new Progress<double>((d) => { SetStatus(null, null, (int)Math.Floor(d)); });
|
||||||
var akiReleaseInfoFile = await DownloadCacheHelper.DownloadFileAsync("release.json", "https://spt-releases.modd.in/release.json", progress);
|
var akiReleaseInfoFile = await DownloadCacheHelper.DownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl, progress);
|
||||||
if (akiReleaseInfoFile == null)
|
if (akiReleaseInfoFile == null)
|
||||||
{
|
{
|
||||||
return Result.FromError("Failed to download release metadata");
|
return Result.FromError("Failed to download release metadata");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using SPTInstaller.Models.Releases;
|
using SPTInstaller.Models.ReleaseInfo;
|
||||||
|
|
||||||
namespace SPTInstaller.Models;
|
namespace SPTInstaller.Models;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class InternalData
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The release information from release.json
|
/// The release information from release.json
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReleaseInfo ReleaseInfo { get; set; }
|
public ReleaseInfo.ReleaseInfo ReleaseInfo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The release download link for the patcher mirror list
|
/// The release download link for the patcher mirror list
|
||||||
|
10
SPTInstaller/Models/ReleaseInfo/ReleaseInfo.cs
Normal file
10
SPTInstaller/Models/ReleaseInfo/ReleaseInfo.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SPTInstaller.Models.ReleaseInfo;
|
||||||
|
public class ReleaseInfo
|
||||||
|
{
|
||||||
|
public string AkiVersion { get; set; }
|
||||||
|
public string ClientVersion { get; set; }
|
||||||
|
public List<ReleaseInfoMirror> Mirrors { get; set; }
|
||||||
|
}
|
||||||
|
|
6
SPTInstaller/Models/ReleaseInfo/ReleaseInfoMirror.cs
Normal file
6
SPTInstaller/Models/ReleaseInfo/ReleaseInfoMirror.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace SPTInstaller.Models.ReleaseInfo;
|
||||||
|
public class ReleaseInfoMirror
|
||||||
|
{
|
||||||
|
public string DownloadUrl { get; set; }
|
||||||
|
public string Hash { get; set; }
|
||||||
|
}
|
@ -7,6 +7,7 @@ using Avalonia.Threading;
|
|||||||
using DialogHostAvalonia;
|
using DialogHostAvalonia;
|
||||||
using Gitea.Api;
|
using Gitea.Api;
|
||||||
using Gitea.Client;
|
using Gitea.Client;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using SPTInstaller.Controllers;
|
using SPTInstaller.Controllers;
|
||||||
@ -14,6 +15,7 @@ using SPTInstaller.CustomControls;
|
|||||||
using SPTInstaller.CustomControls.Dialogs;
|
using SPTInstaller.CustomControls.Dialogs;
|
||||||
using SPTInstaller.Helpers;
|
using SPTInstaller.Helpers;
|
||||||
using SPTInstaller.Models;
|
using SPTInstaller.Models;
|
||||||
|
using SPTInstaller.Models.ReleaseInfo;
|
||||||
|
|
||||||
namespace SPTInstaller.ViewModels;
|
namespace SPTInstaller.ViewModels;
|
||||||
|
|
||||||
@ -267,27 +269,25 @@ public class PreChecksViewModel : ViewModelBase
|
|||||||
// get latest spt version
|
// get latest spt version
|
||||||
InstallButtonText = "Getting latest release ...";
|
InstallButtonText = "Getting latest release ...";
|
||||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Running;
|
InstallButtonCheckState = StatusSpinner.SpinnerState.Running;
|
||||||
|
|
||||||
var repo = new RepositoryApi(Configuration.Default);
|
|
||||||
var akiRepoReleases = await repo.RepoListReleasesAsync("SPT-AKI", "Stable-releases");
|
|
||||||
|
|
||||||
if (akiRepoReleases == null || akiRepoReleases.Count == 0)
|
var progress = new Progress<double>((d) => { });
|
||||||
|
var akiReleaseInfoFile = await DownloadCacheHelper.DownloadFileAsync("release.json", DownloadCacheHelper.ReleaseMirrorUrl, progress);
|
||||||
|
if (akiReleaseInfoFile == null)
|
||||||
{
|
{
|
||||||
InstallButtonText = "Could not get SPT releases from repo";
|
InstallButtonText = "Could not get SPT release metadata";
|
||||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var latestAkiRelease = akiRepoReleases.FindAll(x => !x.Prerelease)[0];
|
|
||||||
|
|
||||||
if (latestAkiRelease == null)
|
var akiReleaseInfo = JsonConvert.DeserializeObject<ReleaseInfo>(File.ReadAllText(akiReleaseInfoFile.FullName));
|
||||||
|
if (akiReleaseInfo == null)
|
||||||
{
|
{
|
||||||
InstallButtonText = "Could not find the 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{latestAkiRelease.TagName}";
|
InstallButtonText = $"Start Install: SPT v{akiReleaseInfo.AkiVersion}";
|
||||||
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
|
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
|
||||||
|
|
||||||
AllowDetailsButton = true;
|
AllowDetailsButton = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user