adding some more logging

This commit is contained in:
IsWaffle 2023-05-22 15:09:00 -04:00
parent 96bf6aaf63
commit 52a283ad37
4 changed files with 41 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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));

View File

@ -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;
}

View File

@ -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");