Merge pull request 'more-logging' (#16) from waffle.lord/SPT-AKI-Installer:more-logging into master
Reviewed-on: CWX/SPT-AKI-Installer#16
This commit is contained in:
commit
5d8b8851a1
@ -25,7 +25,7 @@ namespace SPTInstaller.Aki.Helper
|
||||
{
|
||||
if (expectedHash != null && FileHashHelper.CheckHash(cacheFile, expectedHash))
|
||||
{
|
||||
Log.Information($"Using cached file: {cacheFile.Name}");
|
||||
Log.Information($"Using cached file: {cacheFile.Name} - Hash: {expectedHash}");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -119,8 +119,9 @@ namespace SPTInstaller.Aki.Helper
|
||||
|
||||
return result.Succeeded ? cacheFile : null;
|
||||
}
|
||||
catch
|
||||
catch(Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Error while getting file: {fileName}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -135,8 +136,9 @@ namespace SPTInstaller.Aki.Helper
|
||||
|
||||
return result.Succeeded ? cacheFile : null;
|
||||
}
|
||||
catch
|
||||
catch(Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Error while getting file: {fileName}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using Serilog;
|
||||
using SPTInstaller.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace SPTInstaller.Aki.Helper
|
||||
{
|
||||
@ -49,6 +50,19 @@ namespace SPTInstaller.Aki.Helper
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetRedactedPath(string path)
|
||||
{
|
||||
var nameMatched = Regex.Match(path, @".:\\[uU]sers\\(?<NAME>[^\\]+)");
|
||||
|
||||
if (nameMatched.Success)
|
||||
{
|
||||
var name = nameMatched.Groups["NAME"].Value;
|
||||
return path.Replace(name, "-REDACTED-");
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public static Result CopyDirectoryWithProgress(DirectoryInfo sourceDir, DirectoryInfo targetDir, IProgress<double> progress = null) =>
|
||||
CopyDirectoryWithProgress(sourceDir, targetDir, (msg, prog) => progress?.Report(prog));
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Splat;
|
||||
using Serilog;
|
||||
using Splat;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -76,7 +77,11 @@ namespace SPTInstaller.Helpers
|
||||
var service = Locator.Current.GetService(type);
|
||||
|
||||
if (service == null)
|
||||
throw new InvalidOperationException($"Could not locate service of type '{type.Name}'");
|
||||
{
|
||||
var message = $"Could not locate service of type '{type.Name}'";
|
||||
Log.Error(message);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
return service;
|
||||
}
|
||||
@ -92,7 +97,11 @@ namespace SPTInstaller.Helpers
|
||||
var service = Locator.Current.GetService<T>();
|
||||
|
||||
if (service == null)
|
||||
throw new InvalidOperationException($"Could not locate service of type '{nameof(T)}'");
|
||||
{
|
||||
var message = $"Could not locate service of type '{nameof(T)}'";
|
||||
Log.Error(message);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
return service;
|
||||
}
|
||||
@ -108,7 +117,11 @@ namespace SPTInstaller.Helpers
|
||||
var services = Locator.Current.GetServices<T>().ToArray();
|
||||
|
||||
if (services == null || services.Count() == 0)
|
||||
throw new InvalidOperationException($"Could not locate service of type '{nameof(T)}'");
|
||||
{
|
||||
var message = $"Could not locate service of type '{nameof(T)}'";
|
||||
Log.Error(message);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
public override async Task<IResult> TaskOperation()
|
||||
{
|
||||
SetStatus("Initializing", "");
|
||||
SetStatus("Initializing", $"Target Install Path: {FileHelper.GetRedactedPath(_data.TargetInstallPath)}");
|
||||
|
||||
_data.OriginalGamePath = PreCheckHelper.DetectOriginalGamePath();
|
||||
|
||||
@ -26,6 +26,8 @@ namespace SPTInstaller.Installer_Tasks
|
||||
return Result.FromError("EFT IS NOT INSTALLED!");
|
||||
}
|
||||
|
||||
SetStatus(null, $"Installed EFT Game Path: {FileHelper.GetRedactedPath(_data.OriginalGamePath)}");
|
||||
|
||||
var result = PreCheckHelper.DetectOriginalGameVersion(_data.OriginalGamePath);
|
||||
|
||||
if (!result.Succeeded)
|
||||
@ -35,6 +37,8 @@ namespace SPTInstaller.Installer_Tasks
|
||||
|
||||
_data.OriginalGameVersion = result.Message;
|
||||
|
||||
SetStatus(null, $"Installed EFT Game Version: {_data.OriginalGameVersion}");
|
||||
|
||||
if (_data.OriginalGamePath == null)
|
||||
{
|
||||
return Result.FromError("Unable to find original EFT directory, please make sure EFT is installed. Please also run EFT once");
|
||||
|
@ -9,6 +9,8 @@
|
||||
<PackageIcon>icon.ico</PackageIcon>
|
||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||
<Configurations>Debug;Release;TEST</Configurations>
|
||||
<AssemblyVersion>2.2</AssemblyVersion>
|
||||
<FileVersion>2.2</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -2,6 +2,7 @@
|
||||
using ReactiveUI;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SPTInstaller.ViewModels
|
||||
{
|
||||
@ -10,9 +11,20 @@ namespace SPTInstaller.ViewModels
|
||||
public RoutingState Router { get; } = new RoutingState();
|
||||
public ViewModelActivator Activator { get; } = new ViewModelActivator();
|
||||
|
||||
private string _title;
|
||||
public string Title
|
||||
{
|
||||
get => _title;
|
||||
set => this.RaiseAndSetIfChanged(ref _title, value);
|
||||
}
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
Log.Information("========= LAUNCHER STARTED =========");
|
||||
string? version = Assembly.GetExecutingAssembly().GetName()?.Version?.ToString();
|
||||
|
||||
Title = $"SPT Installer {"v" + version ?? "--unknown version--"}";
|
||||
|
||||
Log.Information($"========= {Title} Started =========");
|
||||
Log.Information(Environment.OSVersion.VersionString);
|
||||
|
||||
Router.Navigate.Execute(new PreChecksViewModel(this));
|
||||
|
@ -27,7 +27,7 @@
|
||||
</Design.DataContext>
|
||||
|
||||
<Grid RowDefinitions="AUTO,*">
|
||||
<cc:TitleBar Title="SPT Installer"
|
||||
<cc:TitleBar Title="{Binding Title}"
|
||||
XButtonCommand="{Binding CloseCommand}"
|
||||
MinButtonCommand="{Binding MinimizeCommand}"
|
||||
/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user