From 86eeba3d8a0f574f80545c28f32bb4905284d88f Mon Sep 17 00:00:00 2001 From: Jordan Russell Date: Tue, 12 Nov 2024 00:07:21 -0600 Subject: [PATCH] Fix missing FChunkStarted check in EndChunk. This was causing an extra empty stream to be written after every chunk (each 2 bytes, with lzma2). --- Projects/Src/Compiler.CompressionHandler.pas | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Projects/Src/Compiler.CompressionHandler.pas b/Projects/Src/Compiler.CompressionHandler.pas index 54b22cfeb..9708f462e 100644 --- a/Projects/Src/Compiler.CompressionHandler.pas +++ b/Projects/Src/Compiler.CompressionHandler.pas @@ -231,15 +231,15 @@ procedure TCompressionHandler.NewChunk(const ACompressorClass: TCustomCompressor procedure TCompressionHandler.EndChunk; begin - if Assigned(FCompressor) then begin - FCompressor.Finish; - { In case we didn't get a ProgressProc call after the final block: } - FCompiler.SetBytesCompressedSoFar(FInitialBytesCompressedSoFar); - FCompiler.AddBytesCompressedSoFar(FChunkBytesRead); - FCompiler.CallIdleProc; - end; - + if not FChunkStarted then + Exit; FChunkStarted := False; + + FCompressor.Finish; + { In case we didn't get a ProgressProc call after the final block: } + FCompiler.SetBytesCompressedSoFar(FInitialBytesCompressedSoFar); + FCompiler.AddBytesCompressedSoFar(FChunkBytesRead); + FCompiler.CallIdleProc; end; procedure TCompressionHandler.CompressFile(const SourceFile: TFile; @@ -315,4 +315,4 @@ procedure TCompressionHandler.ProgressProc(BytesProcessed: Cardinal); FCompiler.CallIdleProc; end; -end. \ No newline at end of file +end.