diff --git a/ReleaseHistory.md b/ReleaseHistory.md index b470eae0b..d54a5bddc 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -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) diff --git a/src/Sarif/FileRegionsCache.cs b/src/Sarif/FileRegionsCache.cs index d3a9df991..fb56cc243 100644 --- a/src/Sarif/FileRegionsCache.cs +++ b/src/Sarif/FileRegionsCache.cs @@ -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) @@ -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); } ///