Skip to content

Commit

Permalink
Be sure to open the hitfile with read access. (#1214)
Browse files Browse the repository at this point in the history
Be sure to open the hitfile with read access.
  • Loading branch information
JamesWTruher committed Sep 9, 2021
1 parent 468b632 commit 8f91b34
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/coverlet.core/Coverage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private void CalculateCoverage()
}

var documentsList = result.Documents.Values.ToList();
using (var fs = _fileSystem.NewFileStream(result.HitsFilePath, FileMode.Open))
using (var fs = _fileSystem.NewFileStream(result.HitsFilePath, FileMode.Open, FileAccess.Read))
using (var br = new BinaryReader(fs))
{
int hitCandidatesCount = br.ReadInt32();
Expand Down Expand Up @@ -442,8 +442,15 @@ private void CalculateCoverage()
}
}

_instrumentationHelper.DeleteHitsFile(result.HitsFilePath);
_logger.LogVerbose($"Hit file '{result.HitsFilePath}' deleted");
try
{
_instrumentationHelper.DeleteHitsFile(result.HitsFilePath);
_logger.LogVerbose($"Hit file '{result.HitsFilePath}' deleted");
}
catch (Exception ex)
{
_logger.LogWarning($"Unable to remove hit file: {result.HitsFilePath} because : {ex.Message}");
}
}
}

Expand Down

0 comments on commit 8f91b34

Please sign in to comment.