Skip to content

Commit

Permalink
Added fix for hash file having a null hash for a file
Browse files Browse the repository at this point in the history
  • Loading branch information
TechieGuy12 committed Jun 19, 2024
1 parent cf283ee commit f1cbffc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 5 additions & 0 deletions FileVerification/CheckSumFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ public bool IsMatch(string file, HashAlgorithm hashAlgorithm)
return false;
}

if (string.IsNullOrWhiteSpace(hashInfo.Hash))
{
hashInfo.Hash = hash;
}

return hashInfo.IsHashEqual(hash);
}
else
Expand Down
7 changes: 4 additions & 3 deletions FileVerification/FileVerification.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<AssemblyName>fv</AssemblyName>
<RootNamespace>TE.FileVerification</RootNamespace>
<Nullable>enable</Nullable>
<FileVersion>1.2.0.0</FileVersion>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<Version>1.2.0</Version>
<FileVersion>1.3.0.0</FileVersion>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<Version>1.3.0</Version>
<AnalysisLevel>latest-all</AnalysisLevel>
<Copyright>© 2024</Copyright>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 1 addition & 6 deletions FileVerification/HashInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class HashInfo
/// <summary>
/// Gets the hash associated with the file.
/// </summary>
public string? Hash { get; private set; }
public string? Hash { get; internal set; }

/// <summary>
/// Gets the full path to the file.
Expand Down Expand Up @@ -95,11 +95,6 @@ private HashInfo(string filePath)
public HashInfo(string filePath, string algorithm, string hash)
: this(filePath)
{
if (hash == null || string.IsNullOrWhiteSpace(hash))
{
throw new ArgumentNullException(nameof(hash));
}

Algorithm = GetAlgorithm(algorithm);
Hash = hash;
}
Expand Down

0 comments on commit f1cbffc

Please sign in to comment.