Compare commits

...

2 Commits

Author SHA1 Message Date
e5f6c681de Merge pull request 'Improve patch creation performance' (#20) from DrakiaXYZ/Patcher:perf-nocompression into main
Reviewed-on: #20

Slightly larger space should be fine, since the installer adds about 10Gb to the space check for misc files (patcher, release, metadata)

LGTM!
2024-06-25 12:54:20 +00:00
DrakiaXYZ
38f2425aeb Improve patch creation performance
- Skip MD5 hash generation if the file size differs, as it's guaranteed to be different
- Disable xdelta compression, LZMA does a better job and quicker
2024-06-24 21:09:40 -07:00

View File

@ -83,6 +83,12 @@ namespace PatcherUtils
var sourceInfo = new FileInfo(SourceFilePath); var sourceInfo = new FileInfo(SourceFilePath);
var targetInfo = new FileInfo(TargetFilePath); var targetInfo = new FileInfo(TargetFilePath);
// Return false if file size differs
if (sourceInfo.Length != targetInfo.Length)
{
return false;
}
using (MD5 md5Service = MD5.Create()) using (MD5 md5Service = MD5.Create())
using (var sourceStream = File.OpenRead(SourceFilePath)) using (var sourceStream = File.OpenRead(SourceFilePath))
using (var targetStream = File.OpenRead(TargetFilePath)) using (var targetStream = File.OpenRead(TargetFilePath))
@ -166,7 +172,7 @@ namespace PatcherUtils
Process.Start(new ProcessStartInfo Process.Start(new ProcessStartInfo
{ {
FileName = LazyOperations.XDelta3Path, FileName = LazyOperations.XDelta3Path,
Arguments = $"-0 -e -f -s \"{SourceFilePath}\" \"{TargetFilePath}\" \"{deltaPath}\"", Arguments = $"-0 -e -f -S none -s \"{SourceFilePath}\" \"{TargetFilePath}\" \"{deltaPath}\"",
CreateNoWindow = true CreateNoWindow = true
}) })
.WaitForExit(); .WaitForExit();