Merge pull request 'add more hash logging' (#49) from waffle.lord/SPT-AKI-Installer:fix/correctly-log-hashes into master

Reviewed-on: CWX/SPT-AKI-Installer#49
This commit is contained in:
IsWaffle 2024-01-20 03:52:03 +00:00
commit 148a8fd232
3 changed files with 17 additions and 4 deletions

View File

@ -14,7 +14,11 @@ public static class DownloadCacheHelper
public static string GetCacheSizeText()
{
if (!Directory.Exists(CachePath))
return "No cache folder";
{
var message = "No cache folder";
Log.Information(message);
return message;
}
var cacheDir = new DirectoryInfo(CachePath);
@ -22,7 +26,9 @@ public static class DownloadCacheHelper
if (cacheSize == -1)
{
return "An error occurred while getting the cache size :(";
var message = "An error occurred while getting the cache size :(";
Log.Error(message);
return message;
}
if (cacheSize == 0)
@ -51,7 +57,11 @@ public static class DownloadCacheHelper
Directory.CreateDirectory(CachePath);
if (!cacheFile.Exists || expectedHash == null)
{
Log.Information($"{cacheFile.Name} {(cacheFile.Exists ? "is in cache" : "NOT in cache")}");
Log.Information($"Expected hash: {(expectedHash == null ? "not provided" : expectedHash)}");
return false;
}
if (FileHashHelper.CheckHash(cacheFile, expectedHash))
{

View File

@ -2,6 +2,7 @@
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using Gitea.Model;
using Serilog;
namespace SPTInstaller.Helpers;
@ -27,6 +28,8 @@ public static class FileHashHelper
var sourceHash = md5Service.ComputeHash(sourceStream);
var expectedHashBytes = Convert.FromBase64String(expectedHash);
Log.Information($"Comparing Hashes :: S: {Convert.ToBase64String(sourceHash)} - E: {expectedHash}");
var matched = Enumerable.SequenceEqual(sourceHash, expectedHashBytes);
return matched;

View File

@ -9,8 +9,8 @@
<PackageIcon>icon.ico</PackageIcon>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
<Configurations>Debug;Release;TEST</Configurations>
<AssemblyVersion>2.27</AssemblyVersion>
<FileVersion>2.27</FileVersion>
<AssemblyVersion>2.28</AssemblyVersion>
<FileVersion>2.28</FileVersion>
<Company>SPT-AKI</Company>
</PropertyGroup>