get release info, log install path before errors
This commit is contained in:
parent
2202a8a492
commit
75e5cd914e
@ -22,7 +22,7 @@
|
||||
|
||||
<Label Grid.Column="1"
|
||||
Content="{Binding PreCheckName, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
Classes.bold="{Binding State, RelativeSource={RelativeSource AncestorType=UserControl}
|
||||
Classes.bold="{Binding State, RelativeSource={RelativeSource AncestorType=UserControl},
|
||||
Converter={StaticResource ResourceKey=IsStateConverter},
|
||||
ConverterParameter=Running}"
|
||||
/>
|
||||
|
@ -5,6 +5,8 @@ using System.Windows.Input;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using DialogHostAvalonia;
|
||||
using Gitea.Api;
|
||||
using Gitea.Client;
|
||||
using ReactiveUI;
|
||||
using Serilog;
|
||||
using SPTInstaller.Controllers;
|
||||
@ -25,7 +27,7 @@ public class PreChecksViewModel : ViewModelBase
|
||||
|
||||
public ICommand DismissUpdateCommand { get; set; }
|
||||
|
||||
public InstallerUpdateInfo UpdateInfo { get; set; } = new InstallerUpdateInfo();
|
||||
public InstallerUpdateInfo UpdateInfo { get; set; } = new();
|
||||
|
||||
private string _installPath;
|
||||
public string InstallPath
|
||||
@ -33,6 +35,14 @@ public class PreChecksViewModel : ViewModelBase
|
||||
get => _installPath;
|
||||
set => this.RaiseAndSetIfChanged(ref _installPath, value);
|
||||
}
|
||||
|
||||
private string _installButtonText;
|
||||
|
||||
public string InstallButtonText
|
||||
{
|
||||
get => _installButtonText;
|
||||
set => this.RaiseAndSetIfChanged(ref _installButtonText, value);
|
||||
}
|
||||
|
||||
private bool _allowInstall;
|
||||
public bool AllowInstall
|
||||
@ -61,12 +71,22 @@ public class PreChecksViewModel : ViewModelBase
|
||||
get => _cacheCheckState;
|
||||
set => this.RaiseAndSetIfChanged(ref _cacheCheckState, value);
|
||||
}
|
||||
|
||||
private StatusSpinner.SpinnerState _installButtonCheckState;
|
||||
public StatusSpinner.SpinnerState InstallButtonCheckState
|
||||
{
|
||||
get => _installButtonCheckState;
|
||||
set => this.RaiseAndSetIfChanged(ref _installButtonCheckState, value);
|
||||
}
|
||||
|
||||
public PreChecksViewModel(IScreen host) : base(host)
|
||||
{
|
||||
var data = ServiceHelper.Get<InternalData?>();
|
||||
var installer = ServiceHelper.Get<InstallController?>();
|
||||
|
||||
InstallButtonText = "Please wait ...";
|
||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Pending;
|
||||
|
||||
if (data == null || installer == null)
|
||||
{
|
||||
NavigateTo(new MessageViewModel(HostScreen, Result.FromError("Failed to get required service for prechecks")));
|
||||
@ -74,6 +94,11 @@ public class PreChecksViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
|
||||
|
||||
data.TargetInstallPath = Environment.CurrentDirectory;
|
||||
InstallPath = data.TargetInstallPath;
|
||||
|
||||
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
|
||||
|
||||
#if !TEST
|
||||
if (data.OriginalGamePath == null)
|
||||
@ -83,11 +108,6 @@ public class PreChecksViewModel : ViewModelBase
|
||||
}
|
||||
#endif
|
||||
|
||||
data.TargetInstallPath = Environment.CurrentDirectory;
|
||||
InstallPath = data.TargetInstallPath;
|
||||
|
||||
Log.Information($"Install Path: {FileHelper.GetRedactedPath(InstallPath)}");
|
||||
|
||||
if (data.OriginalGamePath == data.TargetInstallPath)
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
@ -156,10 +176,38 @@ public class PreChecksViewModel : ViewModelBase
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// run prechecks
|
||||
var result = await installer.RunPreChecks();
|
||||
|
||||
// check for updates
|
||||
await UpdateInfo.CheckForUpdates(Assembly.GetExecutingAssembly().GetName()?.Version);
|
||||
|
||||
// get latest spt version
|
||||
InstallButtonText = "Getting latest release ...";
|
||||
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)
|
||||
{
|
||||
InstallButtonText = "Could not get SPT releases from repo";
|
||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
||||
return;
|
||||
}
|
||||
|
||||
var latestAkiRelease = akiRepoReleases.FindAll(x => !x.Prerelease)[0];
|
||||
|
||||
if (latestAkiRelease == null)
|
||||
{
|
||||
InstallButtonText = "Could not find the latest SPT release";
|
||||
InstallButtonCheckState = StatusSpinner.SpinnerState.Error;
|
||||
return;
|
||||
}
|
||||
|
||||
InstallButtonText = $"Start Install: SPT v{latestAkiRelease.TagName}";
|
||||
InstallButtonCheckState = StatusSpinner.SpinnerState.OK;
|
||||
|
||||
AllowDetailsButton = true;
|
||||
AllowInstall = result.Succeeded;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user