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:
commit
148a8fd232
@ -14,7 +14,11 @@ public static class DownloadCacheHelper
|
|||||||
public static string GetCacheSizeText()
|
public static string GetCacheSizeText()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(CachePath))
|
if (!Directory.Exists(CachePath))
|
||||||
return "No cache folder";
|
{
|
||||||
|
var message = "No cache folder";
|
||||||
|
Log.Information(message);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
var cacheDir = new DirectoryInfo(CachePath);
|
var cacheDir = new DirectoryInfo(CachePath);
|
||||||
|
|
||||||
@ -22,7 +26,9 @@ public static class DownloadCacheHelper
|
|||||||
|
|
||||||
if (cacheSize == -1)
|
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)
|
if (cacheSize == 0)
|
||||||
@ -51,7 +57,11 @@ public static class DownloadCacheHelper
|
|||||||
Directory.CreateDirectory(CachePath);
|
Directory.CreateDirectory(CachePath);
|
||||||
|
|
||||||
if (!cacheFile.Exists || expectedHash == null)
|
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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (FileHashHelper.CheckHash(cacheFile, expectedHash))
|
if (FileHashHelper.CheckHash(cacheFile, expectedHash))
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Gitea.Model;
|
using Gitea.Model;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace SPTInstaller.Helpers;
|
namespace SPTInstaller.Helpers;
|
||||||
|
|
||||||
@ -27,6 +28,8 @@ public static class FileHashHelper
|
|||||||
var sourceHash = md5Service.ComputeHash(sourceStream);
|
var sourceHash = md5Service.ComputeHash(sourceStream);
|
||||||
var expectedHashBytes = Convert.FromBase64String(expectedHash);
|
var expectedHashBytes = Convert.FromBase64String(expectedHash);
|
||||||
|
|
||||||
|
Log.Information($"Comparing Hashes :: S: {Convert.ToBase64String(sourceHash)} - E: {expectedHash}");
|
||||||
|
|
||||||
var matched = Enumerable.SequenceEqual(sourceHash, expectedHashBytes);
|
var matched = Enumerable.SequenceEqual(sourceHash, expectedHashBytes);
|
||||||
|
|
||||||
return matched;
|
return matched;
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<PackageIcon>icon.ico</PackageIcon>
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
|
||||||
<Configurations>Debug;Release;TEST</Configurations>
|
<Configurations>Debug;Release;TEST</Configurations>
|
||||||
<AssemblyVersion>2.27</AssemblyVersion>
|
<AssemblyVersion>2.28</AssemblyVersion>
|
||||||
<FileVersion>2.27</FileVersion>
|
<FileVersion>2.28</FileVersion>
|
||||||
<Company>SPT-AKI</Company>
|
<Company>SPT-AKI</Company>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user