Browse Source

Call Abort immediately when OnExtractionProgress returns False.

Previously, if extraction completed while OnExtractionProgress was running
or soon after, then the function would succeed and not raise EAbort
despite the False result. This was confusing because it made it look like
returning False was having no effect. It would also be problematic if the
user's code performed some sort of teardown action prior to returning
False, but then no exception was raised and execution continued normally.
Jordan Russell 2 months ago
parent
commit
a54bb14ba2
1 changed files with 3 additions and 12 deletions
  1. 3 12
      Projects/Src/Compression.SevenZipDLLDecoder.pas

+ 3 - 12
Projects/Src/Compression.SevenZipDLLDecoder.pas

@@ -674,9 +674,7 @@ begin
     else
       Msg := FResult.SavedFatalException.ClassName;
     InternalErrorFmt('Worker thread terminated unexpectedly with exception: %s', [Msg]);
-  end else if FResult.Res = E_ABORT then
-    Abort
-  else begin
+  end else begin
     var OpRes := FResult.OpRes;
     if OpRes <> kOK then
       BadOperationResultError(OpRes)
@@ -834,22 +832,15 @@ begin
     System.TMonitor.Exit(FLock);
   end;
 
-  var Abort := FAbort;
-  if Abort then
-    Exit;
-
   if (CurrentPath <> '') and Assigned(FOnExtractionProgress) then begin
     { Calls to HandleProgress are already throttled so here we don't have to worry
       about calling the script to often }
     if not FOnExtractionProgress(FExtractedArchiveName, CurrentPath, Progress, ProgressMax) then
-      Abort := True;
+      Abort;
   end;
 
-  if not Abort and DownloadTemporaryFileOrExtractArchiveProcessMessages then
+  if DownloadTemporaryFileOrExtractArchiveProcessMessages then
     Application.ProcessMessages;
-
-  if Abort then
-    FAbort := Abort; { Atomic so no lock }
 end;
 
 { TArchiveExtractToHandleCallback }