FIX: If a temporary tar file is generated during the pack process, and the user subsequently cancels, the temporary tar file will not be deleted

This commit is contained in:
rich2014 2026-06-15 22:36:26 +08:00
commit 81f889e677

View file

@ -265,47 +265,57 @@ begin
end;
procedure TWcxArchiveCopyInOperation.MainExecute;
var
resultCode: Integer;
WcxModule: TWcxModule;
procedure doPack;
var
resultCode: Integer;
WcxModule: TWcxModule;
begin
WcxModule := FWcxArchiveFileSource.WcxModule;
with FStatistics do
begin
if FTarBefore then CurrentFileDoneBytes := -1;
CurrentFileTo:= FWcxArchiveFileSource.ArchiveFileName;
UpdateStatistics(FStatistics);
end;
SetProcessDataProc(wcxInvalidHandle);
WcxModule.WcxSetChangeVolProc(wcxInvalidHandle);
resultCode:= ProcessFilesWithMultiRootPath( self.SourceFiles, @self.doWcxPackFiles );
// Check for errors.
if resultCode <> 0 then
begin
ShowError(Format(rsMsgLogError + rsMsgLogPack,
[FWcxArchiveFileSource.ArchiveFileName +
' : ' + GetErrorMsg(resultCode)]), resultCode, [log_arc_op]);
end
else
begin
LogMessage(Format(rsMsgLogSuccess + rsMsgLogPack,
[FWcxArchiveFileSource.ArchiveFileName]), [log_arc_op], lmtSuccess);
FStatistics.DoneFiles:= FStatistics.TotalFiles;
UpdateStatistics(FStatistics);
end;
end;
begin
SourceFiles.sort;
// Put to TAR archive if needed
if FTarBefore and Tar then Exit;
if FTarBefore and Tar then
Exit;
WcxModule := FWcxArchiveFileSource.WcxModule;
with FStatistics do
begin
if FTarBefore then CurrentFileDoneBytes := -1;
CurrentFileTo:= FWcxArchiveFileSource.ArchiveFileName;
UpdateStatistics(FStatistics);
try
doPack;
finally
// Delete temporary TAR archive if needed
if FTarBefore then
mbDeleteFile(FTarFileName);
end;
SetProcessDataProc(wcxInvalidHandle);
WcxModule.WcxSetChangeVolProc(wcxInvalidHandle);
resultCode:= ProcessFilesWithMultiRootPath( self.SourceFiles, @self.doWcxPackFiles );
// Check for errors.
if resultCode <> 0 then
begin
ShowError(Format(rsMsgLogError + rsMsgLogPack,
[FWcxArchiveFileSource.ArchiveFileName +
' : ' + GetErrorMsg(resultCode)]), resultCode, [log_arc_op]);
end
else
begin
LogMessage(Format(rsMsgLogSuccess + rsMsgLogPack,
[FWcxArchiveFileSource.ArchiveFileName]), [log_arc_op], lmtSuccess);
FStatistics.DoneFiles:= FStatistics.TotalFiles;
UpdateStatistics(FStatistics);
end;
// Delete temporary TAR archive if needed
if FTarBefore then mbDeleteFile(FTarFileName);
end;
procedure TWcxArchiveCopyInOperation.Finalize;