ADD: Added TFileSourceConsultPhase to accurately distinguish between source and target phases, because Source FileSource may be equal to Target FileSource

This commit is contained in:
rich2014 2025-03-02 18:18:26 +08:00
commit d336d6eb73
6 changed files with 20 additions and 12 deletions

View file

@ -1114,7 +1114,7 @@ begin
sourceFS:= params.sourceFS;
targetFS:= params.targetFS;
if params.currentFS = params.sourceFS then
if params.phase=TFileSourceConsultPhase.source then
doSource
else
doTarget;

View file

@ -277,8 +277,8 @@ begin
targetPath:= params.targetPath;
pathType:= GetPathType( targetPath );
if ((params.currentFS=params.sourceFS) and (pathType<>ptAbsolute)) or
((params.currentFS<>params.sourceFS) and (pathType=ptAbsolute)) then begin
if ((params.phase=TFileSourceConsultPhase.source) and (pathType<>ptAbsolute)) or
((params.phase=TFileSourceConsultPhase.target) and (pathType=ptAbsolute)) then begin
if pathType <> ptAbsolute then begin
targetPath:= params.files.Path + targetPath;
targetPath:= ExpandAbsolutePath( targetPath );
@ -286,7 +286,7 @@ begin
params.resultTargetPath:= mountedFS.getRealPath( targetPath );
end;
if params.currentFS = params.sourceFS then
if params.phase=TFileSourceConsultPhase.source then
params.files.Path:= calcBasePath;
end;
@ -296,7 +296,7 @@ var
mountPoint: TMountPoint;
realPath: String;
begin
if params.currentFS <> params.sourceFS then
if params.phase<>TFileSourceConsultPhase.source then
Exit;
if NOT params.partnerFS.IsClass(TWcxArchiveFileSource) then
Exit;
@ -317,7 +317,7 @@ var
i: Integer;
path: String;
begin
if params.currentFS <> params.sourceFS then
if params.phase<>TFileSourceConsultPhase.source then
Exit;
if NOT params.partnerFS.IsClass(TWcxArchiveFileSource) then
Exit;
@ -358,7 +358,7 @@ procedure TMountedFileSourceProcessor.consultMoveOperation(var params: TFileSour
begin
params.consultResult:= fscrNotSupported;
params.handled:= True;
if params.currentFS = params.sourceFS then
if params.phase=TFileSourceConsultPhase.source then
Exit;
if params.sourceFS.GetClass.ClassType <> TFileSystemFileSource then
Exit;

View file

@ -63,7 +63,7 @@ procedure TSearchResultFileSourceProcessor.consultMoveOperation( var params: TFi
var
searchResultFS: ISearchResultFileSource;
begin
if params.currentFS <> params.sourceFS then
if params.phase<>TFileSourceConsultPhase.source then
Exit;
searchResultFS:= params.currentFS as ISearchResultFileSource;

View file

@ -18,8 +18,12 @@ type
TFileSourceConsultResult = ( fscrSuccess, fscrNotImplemented, fscrNotSupported, fscrCancel );
{$scopedEnums on}
TFileSourceConsultPhase = ( source, target );
TFileSourceConsultParams = Record
handled: Boolean;
phase: TFileSourceConsultPhase;
operationType: TFileSourceOperationType;
files: TFiles;

View file

@ -148,6 +148,7 @@ begin
params.handled:= False;
fs:= params.sourceFS;
params.phase:= TFileSourceConsultPhase.source;
params.currentFS:= fs;
params.partnerFS:= params.targetFS;
processor:= fs.GetProcessor;
@ -161,6 +162,7 @@ begin
Exit;
fs:= params.targetFS;
params.phase:= TFileSourceConsultPhase.target;
params.currentFS:= fs;
params.partnerFS:= params.sourceFS;
processor:= fs.GetProcessor;
@ -177,6 +179,7 @@ begin
params.handled:= False;
fs:= params.sourceFS;
params.phase:= TFileSourceConsultPhase.source;
params.currentFS:= fs;
params.partnerFS:= params.targetFS;
processor:= fs.GetProcessor;
@ -190,6 +193,7 @@ begin
Exit;
fs:= params.targetFS;
params.phase:= TFileSourceConsultPhase.target;
params.currentFS:= fs;
params.partnerFS:= params.sourceFS;
processor:= fs.GetProcessor;
@ -204,7 +208,7 @@ var
sourceFS: IFileSource;
targetFS: IFileSource;
begin
if params.currentFS <> params.sourceFS then
if params.phase<>TFileSourceConsultPhase.source then
Exit;
sourceFS:= params.sourceFS;
@ -224,7 +228,7 @@ end;
procedure TDefaultFileSourceProcessor.confirmCopyOperation( var params: TFileSourceConsultParams );
begin
if params.currentFS <> params.sourceFS then
if params.phase<>TFileSourceConsultPhase.source then
Exit;
if NOT StrBegins(params.targetPath, '..') then
@ -241,7 +245,7 @@ var
sourceFS: IFileSource;
targetFS: IFileSource;
begin
if params.currentFS <> params.sourceFS then
if params.phase<>TFileSourceConsultPhase.source then
Exit;
sourceFS:= params.sourceFS;

View file

@ -141,7 +141,7 @@ procedure TiCloudDriverProcessor.consultOperation( var params: TFileSourceConsul
var
dlgResult: TModalResult;
begin
if params.currentFS <> params.sourceFS then
if params.phase <> TFileSourceConsultPhase.source then
Exit;
if NOT TSeedFileUtil.isSeedFiles(params.files) then
Exit;