add more hash logging

This commit is contained in:
IsWaffle 2024-01-19 22:51:06 -05:00
parent 7c873731d2
commit db11225eae
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;
@ -26,6 +27,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);

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>