diff --git a/src/Squirrel/Compression/ChecksumFailedException.cs b/src/Squirrel/Compression/ChecksumFailedException.cs index a693f3a47..1d6d0e179 100644 --- a/src/Squirrel/Compression/ChecksumFailedException.cs +++ b/src/Squirrel/Compression/ChecksumFailedException.cs @@ -10,6 +10,19 @@ public class ChecksumFailedException : Exception /// /// The filename of the package which failed validation /// - public string Filename { get; set; } + public string FilePath { get; } + + /// + public ChecksumFailedException(string filePath) + : this(filePath, "Checksum failed") + { + } + + /// + public ChecksumFailedException(string filePath, string message) + : base(message + $" ({filePath})") + { + FilePath = filePath; + } } } diff --git a/src/Squirrel/Compression/DeltaPackage.cs b/src/Squirrel/Compression/DeltaPackage.cs index c6433bf3d..e9825a113 100644 --- a/src/Squirrel/Compression/DeltaPackage.cs +++ b/src/Squirrel/Compression/DeltaPackage.cs @@ -202,12 +202,12 @@ void verifyPatchedFile(string relativeFilePath, string inputFile, string tempTar if (expectedReleaseEntry.Filesize != actualReleaseEntry.Filesize) { _log.Warn($"Patched file {relativeFilePath} has incorrect size, expected {expectedReleaseEntry.Filesize}, got {actualReleaseEntry.Filesize}"); - throw new ChecksumFailedException() { Filename = relativeFilePath }; + throw new ChecksumFailedException(relativeFilePath); } if (expectedReleaseEntry.SHA1 != actualReleaseEntry.SHA1) { _log.Warn($"Patched file {relativeFilePath} has incorrect SHA1, expected {expectedReleaseEntry.SHA1}, got {actualReleaseEntry.SHA1}"); - throw new ChecksumFailedException() { Filename = relativeFilePath }; + throw new ChecksumFailedException(relativeFilePath); } } } diff --git a/src/Squirrel/Internal/Utility.cs b/src/Squirrel/Internal/Utility.cs index 64637c76d..8091377a3 100644 --- a/src/Squirrel/Internal/Utility.cs +++ b/src/Squirrel/Internal/Utility.cs @@ -154,8 +154,8 @@ public static IEnumerable GetAllFilePathsRecursively(string rootPath) public static string CalculateFileSHA1(string filePath) { Contract.Requires(filePath != null); - - using (var stream = File.OpenRead(filePath)) { + var bufferSize = 1000000; // 1mb + using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize)) { return CalculateStreamSHA1(stream); } }