Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nice-to-haves #2609

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
### Changelog

#### Version - 3.7.2.0 - 8/25/2024
* Added a new button to the installer configuration window for verifying installs. This runs the same code as the verify CLI command, now it's in the UI for easier access. The output of this command
is written to a `.html` file and opened in the default browser.
* When a modlist install fails due to one or more missing non-nexus files, the installer will now write a `.html` file with all the links and instructions, and open it with the default browser. This data was
previsoously only written to the log file.

#### Version - 3.7.1.1 - 8/13/2024
* HOTFIX: buggy release pipeline caused some corruption in the files of 3.7.1.0

Expand Down
38 changes: 38 additions & 0 deletions Wabbajack.App.Wpf/View Models/Installers/InstallerVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
using Wabbajack.Services.OSIntegrated;
using Wabbajack.Util;
using System.Windows.Forms;
using Microsoft.Extensions.DependencyInjection;
using Wabbajack.CLI.Verbs;
using Wabbajack.VFS;

namespace Wabbajack;

Expand Down Expand Up @@ -151,6 +154,8 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
public ReactiveCommand<Unit, Unit> GoToInstallCommand { get; }
public ReactiveCommand<Unit, Unit> BeginCommand { get; }

public ReactiveCommand<Unit, Unit> VerifyCommand { get; }

public InstallerVM(ILogger<InstallerVM> logger, DTOSerializer dtos, SettingsManager settingsManager, IServiceProvider serviceProvider,
SystemParametersConstructor parametersConstructor, IGameLocator gameLocator, LogStream loggerProvider, ResourceMonitor resourceMonitor,
Wabbajack.Services.OSIntegrated.Configuration configuration, HttpClient client, DownloadDispatcher dispatcher, IEnumerable<INeedsLogin> logins,
Expand All @@ -175,6 +180,8 @@ public InstallerVM(ILogger<InstallerVM> logger, DTOSerializer dtos, SettingsMana
BackCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView));

BeginCommand = ReactiveCommand.Create(() => BeginInstall().FireAndForget());

VerifyCommand = ReactiveCommand.Create(() => Verify().FireAndForget());

OpenReadmeCommand = ReactiveCommand.Create(() =>
{
Expand Down Expand Up @@ -455,6 +462,37 @@ private void ConfirmOverwrite()
Installer.Location.TargetPath = prev;
}

private async Task Verify()
{
await Task.Run(async () =>
{
InstallState = InstallState.Installing;

StatusText = $"Verifying {ModList.Name}";


var cmd = new VerifyModlistInstall(_serviceProvider.GetRequiredService<ILogger<VerifyModlistInstall>>(), _dtos,
_serviceProvider.GetRequiredService<IResource<FileHashCache>>(),
_serviceProvider.GetRequiredService<TemporaryFileManager>());

var result = await cmd.Run(ModListLocation.TargetPath, Installer.Location.TargetPath, _cancellationToken);

if (result != 0)
{
TaskBarUpdate.Send($"Error during verification of {ModList.Name}", TaskbarItemProgressState.Error);
InstallState = InstallState.Failure;
StatusText = $"Error during install of {ModList.Name}";
StatusProgress = Percent.Zero;
}
else
{
TaskBarUpdate.Send($"Finished verification of {ModList.Name}", TaskbarItemProgressState.Normal);
InstallState = InstallState.Success;
}

});
}

private async Task BeginInstall()
{
await Task.Run(async () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<local:BeginButton Grid.Row="1"
x:Name="BeginButton"
Expand All @@ -104,12 +105,12 @@
Foreground="{StaticResource WarningBrush}"
Kind="ExclamationTriangleSolid" />
<CheckBox Grid.Row="2" Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
x:Name="OverwriteCheckBox"
Content="Overwrite Installation"
IsChecked="False"
ToolTip="Confirm to overwrite files in install folder.">
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
x:Name="OverwriteCheckBox"
Content="Overwrite Installation"
IsChecked="False"
ToolTip="Confirm to overwrite files in install folder.">
<CheckBox.Style>
<Style TargetType="CheckBox">
<Setter Property="Opacity" Value="0.6" />
Expand All @@ -121,6 +122,13 @@
</Style>
</CheckBox.Style>
</CheckBox>
<Button Grid.Row="3" Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
x:Name="VerifyButton"
Content="Verify Installation"
ToolTip="Scan the output folders, creating a report on any corrupt or missing files.">
</Button>
</Grid>
</Grid>
</rxui:ReactiveUserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public InstallationConfigurationView()
this.WhenAny(x => x.ViewModel.BeginCommand)
.BindToStrict(this, x => x.BeginButton.Command)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.VerifyCommand)
.BindToStrict(this, x => x.VerifyButton.Command)
.DisposeWith(dispose);
this.BindStrict(ViewModel, vm => vm.OverwriteFiles, x => x.OverwriteCheckBox.IsChecked)
.DisposeWith(dispose);

Expand All @@ -48,6 +51,11 @@ public InstallationConfigurationView()
.Select(v => !v.Failed)
.BindToStrict(this, view => view.BeginButton.IsEnabled)
.DisposeWith(dispose);

this.WhenAnyValue(x => x.ViewModel.ErrorState)
.Select(v => !v.Failed)
.BindToStrict(this, view => view.VerifyButton.IsEnabled)
.DisposeWith(dispose);

this.WhenAnyValue(x => x.ViewModel.ErrorState)
.Select(v => v.Reason)
Expand Down
1 change: 1 addition & 0 deletions Wabbajack.App.Wpf/Wabbajack.App.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

<ItemGroup>
<ProjectReference Include="..\Wabbajack.CLI.Builder\Wabbajack.CLI.Builder.csproj" />
<ProjectReference Include="..\Wabbajack.CLI\Wabbajack.CLI.csproj" />
<ProjectReference Include="..\Wabbajack.Services.OSIntegrated\Wabbajack.Services.OSIntegrated.csproj" />
</ItemGroup>

Expand Down
33 changes: 29 additions & 4 deletions Wabbajack.CLI/Verbs/VerifyModlistInstall.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -26,11 +28,12 @@ public class VerifyModlistInstall
private readonly DTOSerializer _dtos;
private readonly ILogger<VerifyModlistInstall> _logger;

public VerifyModlistInstall(ILogger<VerifyModlistInstall> logger, DTOSerializer dtos, IResource<FileHashCache> limiter)
public VerifyModlistInstall(ILogger<VerifyModlistInstall> logger, DTOSerializer dtos, IResource<FileHashCache> limiter, TemporaryFileManager temporaryFileManager)
{
_limiter = limiter;
_logger = logger;
_dtos = dtos;
_temporaryFileManager = temporaryFileManager;
}

public static VerbDefinition Definition = new("verify-modlist-install", "Verify a modlist installed correctly",
Expand All @@ -42,6 +45,7 @@ public VerifyModlistInstall(ILogger<VerifyModlistInstall> logger, DTOSerializer
});

private readonly IResource<FileHashCache> _limiter;
private readonly TemporaryFileManager _temporaryFileManager;


public async Task<int> Run(AbsolutePath modlistLocation, AbsolutePath installFolder, CancellationToken token)
Expand All @@ -52,7 +56,9 @@ public async Task<int> Run(AbsolutePath modlistLocation, AbsolutePath installFol
_logger.LogInformation("Indexing files");
var byTo = list.Directives.ToDictionary(d => d.To);

var reportFile = _temporaryFileManager.CreateFile(Ext.Html);


_logger.LogInformation("Scanning files");
var errors = await list.Directives.PMapAllBatchedAsync(_limiter, async directive =>
{
Expand All @@ -68,7 +74,7 @@ public async Task<int> Run(AbsolutePath modlistLocation, AbsolutePath installFol
return new Result
{
Path = directive.To,
Message = $"File does not exist directive {directive.GetType()}"
Message = $"File does not exist"
};
}

Expand Down Expand Up @@ -112,11 +118,30 @@ public async Task<int> Run(AbsolutePath modlistLocation, AbsolutePath installFol
_logger.LogInformation("Found {Count} errors", errors.Count);


foreach (var error in errors)

{
_logger.LogError("{File} | {Message}", error.Path, error.Message);
await using var stream = new StreamWriter(reportFile.Path.Open(FileMode.Create, FileAccess.Write));
await stream.WriteLineAsync(
"<html><head></head><body>");
await stream.WriteLineAsync($"<h1>Verification Report for {modlistLocation}</h1>");

foreach (var error in errors)
{
if (error == null) continue;
await stream.WriteLineAsync($"<div class=\"error\">{error.Message} | {error.Path}</div>");
_logger.LogError("{File} | {Message}", error.Path, error.Message);
}

await stream.WriteLineAsync("</body></html>");
}

_logger.LogInformation("Report written to {Report}", reportFile.Path);

Process.Start(new ProcessStartInfo("cmd.exe", $"/c start {reportFile}")
{
CreateNoWindow = true,
});


return 0;
}
Expand Down
48 changes: 48 additions & 0 deletions Wabbajack.Installer/StandardInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
Expand All @@ -22,6 +23,7 @@
using Wabbajack.DTOs.BSA.FileStates;
using Wabbajack.DTOs.Directives;
using Wabbajack.DTOs.DownloadStates;
using Wabbajack.DTOs.Interventions;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Hashing.PHash;
using Wabbajack.Hashing.xxHash64;
Expand Down Expand Up @@ -123,6 +125,12 @@ public override async Task<bool> Begin(CancellationToken token)
var missing = ModList.Archives.Where(a => !HashedArchives.ContainsKey(a.Hash)).ToList();
if (missing.Count > 0)
{
if (missing.Any(m => m.State is not Nexus))
{
ShowMissingManualReport(missing.Where(m => m.State is not Nexus).ToArray());
return false;
}

foreach (var a in missing)
_logger.LogCritical("Unable to download {name} ({primaryKeyString})", a.Name,
a.State.PrimaryKeyString);
Expand Down Expand Up @@ -168,6 +176,46 @@ public override async Task<bool> Begin(CancellationToken token)
return true;
}

private void ShowMissingManualReport(Archive[] toArray)
{
_logger.LogError("Writing Manual helper report");
var report = _configuration.Downloads.Combine("MissingManuals.html");
{
using var writer = new StreamWriter(report.Open(FileMode.Create, FileAccess.Write, FileShare.None));
writer.Write("<html><head><title>Missing Manual Downloads</title></head><body>");
writer.Write("<h1>Missing Manual Downloads</h1>");
writer.Write(
"<p>Wabbajack was unable to download the following archives automaticall. Please download them manually and place them in the downloads folder you chose during the install setup.</p>");
foreach (var archive in toArray)
{
switch (archive.State)
{
case Manual manual:
writer.Write($"<h3>{archive.Name}</h1>");
writer.Write($"<p>{manual.Prompt}</p>");
writer.Write($"<p>Download URL: <a href=\"{manual.Url}\">{manual.Url}</a></p>");
break;
case MediaFire mediaFire:
writer.Write($"<h3>{archive.Name}</h1>");
writer.Write($"<p>Download URL: <a href=\"{mediaFire.Url}\">{mediaFire.Url}</a></p>");
break;
default:
writer.Write($"<h3>{archive.Name}</h1>");
writer.Write($"<p>Unknown download type</p>");
writer.Write($"<p>Primary Key (may not be helpful): <a href=\"{archive.State.PrimaryKeyString}\">{archive.State.PrimaryKeyString}</a></p>");
break;
}
}

writer.Write("</body></html>");
}

Process.Start(new ProcessStartInfo("cmd.exe", $"/c start {report}")
{
CreateNoWindow = true,
});
}

private Task RemapMO2File()
{
var iniFile = _configuration.Install.Combine("ModOrganizer.ini");
Expand Down
Loading