summaryrefslogtreecommitdiff
path: root/UCoreWorkers.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UCoreWorkers.pas')
-rw-r--r--UCoreWorkers.pas38
1 files changed, 26 insertions, 12 deletions
diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas
index 75a9453..70ac89f 100644
--- a/UCoreWorkers.pas
+++ b/UCoreWorkers.pas
@@ -978,6 +978,12 @@ end;
if Error <> nil then begin
// Error handling
if FCopySkipAllErrors then Exit;
+ if (g_error_matches (Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED))) then begin
+ FCopyErrorHandledInProgress := True;
+ FCopySilentCancel := True;
+ Result := False;
+ Exit;
+ end;
GetCopyProgressErrorLabels(TWorkerThread(Sender), Error, s, s2);
case ShowDirDeleteDialog(DIR_DELETE_SET_COPY_ERROR, s, s2, StrToUTF8(Error^.message)) of
DIR_DELETE_IGNORE : Result := True;
@@ -1013,6 +1019,16 @@ end;
procedure TWorkerThread.CopyFilesWorker;
var DefResponse: integer; // Global variables for this function
+ procedure PropagateMaskedCopyError(Error: PPGError; LocalError: PGError; MaskErrorCode: TuxcmdErrorEnum);
+ begin
+ // Mask everything except of cancellation codes
+ if (g_error_matches (LocalError, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED))) then
+ g_propagate_error (Error, LocalError)
+ else begin
+ g_set_error(Error, TUXCMD_ERROR, gint(MaskErrorCode), LocalError^.message);
+ g_error_free(LocalError);
+ end;
+ end;
// Returns True if file was successfully copied, if not, the file will be deleted in LocalCopyFile
function ManualCopyFile(SourceFile, DestFile: string; Append: boolean; Error: PPGError): boolean;
@@ -1028,8 +1044,7 @@ var DefResponse: integer; // Global variables for this function
DebugMsg(['ManualCopyFile: ', SourceFile, ' ---> ', DestFile]);
fsrc := SrcEngine.OpenFile(SourceFile, omRead, @LocalError);
if fsrc = nil then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_OPEN), LocalError^.message);
- g_error_free(LocalError);
+ PropagateMaskedCopyError(Error, LocalError, TUXCMD_ERROR_SOURCE_OPEN);
CopyFilesWorker_ProgressFunc(Self, 0, Error^); // Cannot open source file
Exit;
end;
@@ -1037,8 +1052,7 @@ var DefResponse: integer; // Global variables for this function
else fdst := DestEngine.OpenFile(DestFile, omWrite, @LocalError);
if fdst = nil then begin
SrcEngine.CloseFile(fsrc, nil);
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_OPEN), LocalError^.message);
- g_error_free(LocalError);
+ PropagateMaskedCopyError(Error, LocalError, TUXCMD_ERROR_TARGET_OPEN);
CopyFilesWorker_ProgressFunc(Self, 0, Error^); // Cannot open target file
Exit;
end;
@@ -1055,8 +1069,7 @@ var DefResponse: integer; // Global variables for this function
// Read block
BytesRead := SrcEngine.ReadFile(fsrc, Buffer, BSize, @LocalError);
if BytesRead < 0 then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_READ), LocalError^.message);
- g_error_free(LocalError);
+ PropagateMaskedCopyError(Error, LocalError, TUXCMD_ERROR_SOURCE_READ);
LocalError := nil;
Result := CopyFilesWorker_ProgressFunc(Self, BytesDone, Error^); // Cannot read from source file
if Result then begin
@@ -1075,8 +1088,7 @@ var DefResponse: integer; // Global variables for this function
BytesRemaining := BytesRemaining - BytesWritten;
until (BytesRemaining = 0) or (BytesWritten <= 0);
if BytesWritten < 0 then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_WRITE), LocalError^.message);
- g_error_free(LocalError);
+ PropagateMaskedCopyError(Error, LocalError, TUXCMD_ERROR_TARGET_WRITE);
LocalError := nil;
Result := False;
CopyFilesWorker_ProgressFunc(Self, BytesDone, Error^); // Cannot write to target file
@@ -1092,8 +1104,7 @@ var DefResponse: integer; // Global variables for this function
if not DestEngine.CloseFile(fdst, @LocalError) then
if Result then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_CLOSE), LocalError^.message);
- g_error_free(LocalError);
+ PropagateMaskedCopyError(Error, LocalError, TUXCMD_ERROR_TARGET_CLOSE);
Result := False;
SrcEngine.CloseFile(fsrc, nil);
CopyFilesWorker_ProgressFunc(Self, BytesDone, Error^); // Cannot close target file
@@ -1101,8 +1112,7 @@ var DefResponse: integer; // Global variables for this function
end;
if not SrcEngine.CloseFile(fsrc, @LocalError) then
if Result then begin
- g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_CLOSE), LocalError^.message);
- g_error_free(LocalError);
+ PropagateMaskedCopyError(Error, LocalError, TUXCMD_ERROR_SOURCE_CLOSE);
Result := CopyFilesWorker_ProgressFunc(Self, BytesDone, Error^); // Cannot close source file
if Result then begin
// user has chosen to ignore the error
@@ -1365,6 +1375,10 @@ var DefResponse: integer; // Global variables for this function
if FCopySilentCancel then Result := False; // Break the processing
Exit;
end;
+ if (g_error_matches (Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED))) then begin
+ Result := False;
+ Exit;
+ end;
GetCopyProgressErrorLabels(Self, Error, s, s2);
s3 := StrToUTF8(Error^.message);
if (Error^.domain = TUXCMD_ERROR) then