From d7ad13f338b1c403741ad2104247db1c175b3303 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 29 Nov 2009 23:30:02 +0100 Subject: Fix callback setting for non-archiving modules --- UCoreWorkers.pas | 8 ++++---- vfs/UVFSCore.pas | 60 ++++++++++++++++++++++++++++++-------------------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas index 218c43a..8ded910 100644 --- a/UCoreWorkers.pas +++ b/UCoreWorkers.pas @@ -1395,9 +1395,9 @@ begin if MaxSize < 2 then ParamFloat1 := 1 else ParamFloat1 := 100 / (MaxSize - 1); if List.Count > 0 then begin StartPassed := True; - if (SrcEngine is TVFSEngine) and (SrcEngine as TVFSEngine).ArchiveMode then + if SrcEngine is TVFSEngine then StartPassed := StartPassed and (SrcEngine as TVFSEngine).StartCopyOperation(SenderThread, @CopyFilesWorker_ErrorFunc, @vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_progress_callback, SenderThread); - if (DestEngine is TVFSEngine) and (DestEngine as TVFSEngine).ArchiveMode then + if DestEngine is TVFSEngine then StartPassed := StartPassed and (DestEngine as TVFSEngine).StartCopyOperation(SenderThread, @CopyFilesWorker_ErrorFunc, @vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_progress_callback, SenderThread); if StartPassed then @@ -1441,9 +1441,9 @@ begin end; // We need to ensure these to be called in case of error - if (SrcEngine is TVFSEngine) and (SrcEngine as TVFSEngine).ArchiveMode then + if SrcEngine is TVFSEngine then (SrcEngine as TVFSEngine).StopCopyOperation(SenderThread, @CopyFilesWorker_ErrorFunc); - if (DestEngine is TVFSEngine) and (DestEngine as TVFSEngine).ArchiveMode then + if DestEngine is TVFSEngine then (DestEngine as TVFSEngine).StopCopyOperation(SenderThread, @CopyFilesWorker_ErrorFunc); end; diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index ff5445d..3e14618 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -843,23 +843,25 @@ end; function TVFSEngine.StartCopyOperation(Sender: Pointer; ErrorFunc: TEngineErrorFunc; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer): boolean; var Res: TVFSResult; begin - Result := False; + Result := not ArchiveMode; try if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); - if @FSourcePlugin.FVFSStartCopyOperation <> nil then begin - Res := FSourcePlugin.FVFSStartCopyOperation(FGlobs); - Result := Res = cVFS_OK; - // * TODO: Port to GError - if (Res <> cVFS_OK) and Assigned(ErrorFunc) then - case Res of - cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, 'StartCopyOperation'); - cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, 'StartCopyOperation'); - cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, 'StartCopyOperation'); - cVFS_Cancelled: ErrorFunc(Sender, 0, 0, 'StartCopyOperation'); - end; - end else - ErrorFunc(Sender, 2, 0, 'StartCopyOperation not supported'); + if ArchiveMode then begin + if @FSourcePlugin.FVFSStartCopyOperation <> nil then begin + Res := FSourcePlugin.FVFSStartCopyOperation(FGlobs); + Result := Res = cVFS_OK; + // * TODO: Port to GError + if (Res <> cVFS_OK) and Assigned(ErrorFunc) then + case Res of + cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, 'StartCopyOperation'); + cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, 'StartCopyOperation'); + cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, 'StartCopyOperation'); + cVFS_Cancelled: ErrorFunc(Sender, 0, 0, 'StartCopyOperation'); + end; + end else + ErrorFunc(Sender, 2, 0, 'StartCopyOperation not supported'); + end; except on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.StartCopyOperation(Sender=', QWord(Sender), '): (', E.ClassName, '): ', E.Message]); end; @@ -868,23 +870,25 @@ end; function TVFSEngine.StopCopyOperation(Sender: Pointer; ErrorFunc: TEngineErrorFunc): boolean; var Res: TVFSResult; begin - Result := False; + Result := not ArchiveMode; try if @FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); - if @FSourcePlugin.FVFSStopCopyOperation <> nil then begin - Res := FSourcePlugin.FVFSStopCopyOperation(FGlobs); - Result := Res = cVFS_OK; - // * TODO: Port to GError - if (Res <> cVFS_OK) and Assigned(ErrorFunc) then - case Res of - cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, 'StopCopyOperation'); - cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, 'StopCopyOperation'); - cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, 'StopCopyOperation'); - cVFS_Cancelled: ErrorFunc(Sender, 0, 0, 'StopCopyOperation'); - end; - end else - ErrorFunc(Sender, 5, 0, 'StopCopyOperation not supported'); + if ArchiveMode then begin + if @FSourcePlugin.FVFSStopCopyOperation <> nil then begin + Res := FSourcePlugin.FVFSStopCopyOperation(FGlobs); + Result := Res = cVFS_OK; + // * TODO: Port to GError + if (Res <> cVFS_OK) and Assigned(ErrorFunc) then + case Res of + cVFS_ReadErr: Result := ErrorFunc(Sender, 6, 0, 'StopCopyOperation'); + cVFS_WriteErr: Result := ErrorFunc(Sender, 7, 0, 'StopCopyOperation'); + cVFS_mallocFailed: ErrorFunc(Sender, 1, 0, 'StopCopyOperation'); + cVFS_Cancelled: ErrorFunc(Sender, 0, 0, 'StopCopyOperation'); + end; + end else + ErrorFunc(Sender, 5, 0, 'StopCopyOperation not supported'); + end; except on E: Exception do DebugMsg(['*** Exception raised in TVFSEngine.StopCopyOperation(Sender=', QWord(Sender), '): (', E.ClassName, '): ', E.Message]); end; -- cgit v1.2.3