Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #181 from finos/db-contrib/develop
Browse files Browse the repository at this point in the history
Db contrib/develop
  • Loading branch information
MaxWellHays authored Sep 11, 2020
2 parents 5bb8a74 + eef814f commit 1849d5d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions desktop/src/Plexus.Utils/BaseJsonFileRegistryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,32 @@ private T LoadRegistry(string jsonFileName)
}

memoryStream.Position = 0;
var md5 = CalculateMd5(memoryStream);
var sha1 = CalculateSha1(memoryStream);
var creationTime = File.GetCreationTime(jsonFileName);
var lastWriteTime = File.GetLastWriteTime(jsonFileName);
var length = memoryStream.Length;

Log.Info($"Successfully loaded registry from {jsonFileName}. CreationTime: {creationTime}; LastWriteTime: {lastWriteTime}; Length: {length}; MD5: {md5}");
Log.Info($"Successfully loaded registry from {jsonFileName}. CreationTime: {creationTime}; LastWriteTime: {lastWriteTime}; Length: {length}; SHA1: {sha1}");

return registry;
}
}


private string CalculateMd5(Stream stream)
private string CalculateSha1(Stream stream)
{
using (var md5 = MD5.Create())
try
{
using (var sha1 = SHA1.Create())
{
var hash = sha1.ComputeHash(stream);
return ToHashString(hash);
}
}
catch (Exception ex)
{
var hash = md5.ComputeHash(stream);
return ToHashString(hash);
Log.Warn(ex, "Failed to calculate SHA1 hash");
return string.Empty;
}
}

Expand Down

0 comments on commit 1849d5d

Please sign in to comment.