From dcca0d691870b9f8be4be66d2e6d54e4635220dd Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 25 Oct 2024 18:19:18 +0200 Subject: Handle zero file sizes in the Copy progress dialog Division by zero... --- UCoreWorkers.pas | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas index 70ac89f..8c35c49 100644 --- a/UCoreWorkers.pas +++ b/UCoreWorkers.pas @@ -1004,9 +1004,12 @@ end; FCopyErrorHandledInProgress := not Result; end else begin // Progress update - if BytesDone = 0 then UpdateProgress1(0, '0%') - else UpdateProgress1(BytesDone, Format('%d%%', [Round(BytesDone / FFileSize * 100)])); - UpdateProgress2(FTotalDone + BytesDone, Format('%d%%', [Round((FTotalDone + BytesDone) / FTotalSize * 100)])); + if (BytesDone = 0) or (FFileSize = 0) + then UpdateProgress1(0, '0%') + else UpdateProgress1(BytesDone, Format('%d%%', [Round(BytesDone / FFileSize * 100)])); + if FTotalSize = 0 + then UpdateProgress2(0, '0%') + else UpdateProgress2(FTotalDone + BytesDone, Format('%d%%', [Round((FTotalDone + BytesDone) / FTotalSize * 100)])); CommitGUIUpdate; end; end else DebugMsg(['*** CopyFilesWorker: Sender is not TWorkerThread']); -- cgit v1.2.3