Added extra logging when generating hashes (#376)

When hashing large files, it can appear that nothing is happening. This
change adds log entries before hashes are generated to indicate that
hashing is about to begin.
This commit is contained in:
Michael Green
2024-06-26 06:25:05 +10:00
committed by GitHub
parent c7b6233ad6
commit ccf9afd561

View File

@@ -19,7 +19,8 @@ namespace gaseous_server.Classes
if (ObjectToCheck == null || ObjectToCheck == System.DBNull.Value)
{
return IfNullValue;
} else
}
else
{
return ObjectToCheck;
}
@@ -43,11 +44,13 @@ namespace gaseous_server.Classes
{
var xmlStream = File.OpenRead(FileName);
Logging.Log(Logging.LogType.Information, "Hash File", "Generating MD5 hash for file: " + FileName);
var md5 = MD5.Create();
byte[] md5HashByte = md5.ComputeHash(xmlStream);
string md5Hash = BitConverter.ToString(md5HashByte).Replace("-", "").ToLowerInvariant();
_md5hash = md5Hash;
Logging.Log(Logging.LogType.Information, "Hash File", "Generating SHA1 hash for file: " + FileName);
var sha1 = SHA1.Create();
xmlStream.Position = 0;
byte[] sha1HashByte = sha1.ComputeHash(xmlStream);