Skip to content

Commit

Permalink
Revert "Fix Hash issue in 4.1.0 (#2667)" (#2670)
Browse files Browse the repository at this point in the history
This reverts commit 37fa749.
  • Loading branch information
shaopeng-gh committed May 16, 2023
1 parent 140d730 commit fdec8a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
1 change: 0 additions & 1 deletion ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* BRK: Remove unused `quiet` parameter from `SarifLogger`. [#2639]https://github.com/microsoft/sarif-sdk/pull/2639
* BRK: Remove `ComputeHashData` and `AnalysisTargetToHashDataMap` properties from `SarifLogger` (in preference of new `fileRegionsCache` parameter. [#2639](https://github.com/microsoft/sarif-sdk/pull/2639)
* BRK: Eliminate proactive hashing of artifacts in `SarifLogger` constructor when `OptionallyEmittedData.Hashes` is specified. [#2639](https://github.com/microsoft/sarif-sdk/pull/2639)
* BUG: Fixed incorrect hashes being returned when `--insert hashes` is enabled. [#2667](https://github.com/microsoft/sarif-sdk/pull/2667)
* BUG: Fixed `ERR999.UnhandledEngineException: System.InvalidOperationException: This operation is not supported for a relative URI` when running in Linux with files skipped due to zero byte size. [#2664](https://github.com/microsoft/sarif-sdk/pull/2664)
* BUG: Properly report skipping empty files (rather than reporting file was skipped due to exceeding size limits). [#2660](https://github.com/microsoft/sarif-sdk/pull/2660)
* BUG: Update user messages and code comments that refer to `--force` (replaced by `--log ForceOverwrite`). [#2656](https://github.com/microsoft/sarif-sdk/pull/2656)
Expand Down
20 changes: 4 additions & 16 deletions src/Sarif/FileRegionsCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,14 @@ private static void PopulateCharLength(NewLineIndex lineIndex, Region region)
public HashData GetHashData(Uri uri, string fileText = null)
{
string path = uri.GetFilePath();

if (fileText != null)
{
_fileTextCache[path] = fileText;
_hashDataCache[path] = HashUtilities.ComputeHashesForText(fileText);
return _hashDataCache[path];
}

if (_hashDataCache.ContainsKey(path))
{
return _hashDataCache[path];
}
fileText = _fileTextCache[path];

_hashDataCache[path] = HashUtilities.ComputeHashes(path);
return _hashDataCache[path];
return HashUtilities.ComputeHashesForText(fileText);
}

public NewLineIndex GetNewLineIndex(Uri uri, string fileText = null)
Expand Down Expand Up @@ -429,13 +422,8 @@ private string RetrieveTextForFile(string path)

private HashData BuildHashDataForFile(string path)
{
if (_hashDataCache.ContainsKey(path))
{
return _hashDataCache[path];
}

_hashDataCache[path] = HashUtilities.ComputeHashes(path);
return _hashDataCache[path];
string fileText = _fileTextCache[path];
return HashUtilities.ComputeHashesForText(fileText);
}

/// <summary>
Expand Down

0 comments on commit fdec8a9

Please sign in to comment.