Skip to content

Commit

Permalink
Merge branch '309'
Browse files Browse the repository at this point in the history
# Conflicts:
#	models/wfx/MailRuCloudWFX.pas
  • Loading branch information
pozitronik committed Jan 27, 2024
2 parents 5917ed3 + 8f31c38 commit 1f837fd
Showing 1 changed file with 74 additions and 80 deletions.
154 changes: 74 additions & 80 deletions models/wfx/MailRuCloudWFX.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ function TMailRuCloudWFX.FsFindClose(Hdl: THandle): Integer;
end;

function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDDATAW): THandle;
var //Получение первого файла в папке. Result тоталом не используется (можно использовать для работы плагина).
var //Получение первого файла в папке. Result не используется (можно использовать для работы плагина).
RealPath: TRealPath;
getResult: Integer;
SkipListDelete, SkipListRenMov, CanAbortRenMov, RenMovAborted: Boolean;
Expand All @@ -1066,7 +1066,6 @@ function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDD
begin
ThreadSkipListDelete.TryGetValue(GetCurrentThreadID(), SkipListDelete);
ThreadSkipListRenMov.TryGetValue(GetCurrentThreadID(), SkipListRenMov);

ThreadCanAbortRenMov.TryGetValue(GetCurrentThreadID(), CanAbortRenMov);

if (CanAbortRenMov and TCProgress.Progress(Path)) then
Expand All @@ -1079,93 +1078,88 @@ function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDD

if SkipListDelete or SkipListRenMov or RenMovAborted then
begin
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_NO_MORE_FILES); //in some unpredictable situations causes unintentional exit (#308)
exit;
end;

//Result := FIND_NO_MORE_FILES;
GlobalPath := Path;
if GlobalPath = '\' then
begin //список соединений
Accounts := AccountSettings.GetAccountsList([ATPrivate, ATPublic], SettingsManager.Settings.EnabledVirtualTypes);
if (Accounts.Count > 0) then
begin
FindData := GetFindDataEmptyDir(Accounts[0]);
FileCounter := 1;
Result := FIND_ROOT_DIRECTORY;
end else begin
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_NO_MORE_FILES); //in some unpredictable situations causes unintentional exit (#308)
exit;
end;
CurrentListing := [];
SetLastError(ERROR_NO_MORE_FILES);
Result := FIND_NO_MORE_FILES;
end else begin
RealPath.FromPath(GlobalPath);
CurrentCloud := ConnectionManager.Get(RealPath.account, getResult);

if getResult <> CLOUD_OPERATION_OK then
begin
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_ACCESS_DENIED);
exit;
end;
//Result := FIND_NO_MORE_FILES;
GlobalPath := Path;
if GlobalPath = '\' then
begin //список соединений
Accounts := AccountSettings.GetAccountsList([ATPrivate, ATPublic], SettingsManager.Settings.EnabledVirtualTypes);
if (Accounts.Count > 0) then
begin
FindData := GetFindDataEmptyDir(Accounts[0]);
FileCounter := 1;
Result := FIND_ROOT_DIRECTORY;
end else begin
Result := INVALID_HANDLE_VALUE; //Нельзя использовать exit
SetLastError(ERROR_NO_MORE_FILES);
end;
end else begin
RealPath.FromPath(GlobalPath);
CurrentCloud := ConnectionManager.Get(RealPath.account, getResult);

if not Assigned(CurrentCloud) then
begin
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_PATH_NOT_FOUND);
exit;
end;
if getResult <> CLOUD_OPERATION_OK then
begin
SetLastError(ERROR_ACCESS_DENIED);
exit(INVALID_HANDLE_VALUE);
end;

if RealPath.trashDir then
begin
if not CurrentCloud.getTrashbinListing(CurrentListing) then
SetLastError(ERROR_PATH_NOT_FOUND);
end else if RealPath.sharedDir then
begin
if not CurrentCloud.getSharedLinksListing(CurrentListing) then
SetLastError(ERROR_PATH_NOT_FOUND); //that will be interpreted as symlinks later
end else if RealPath.invitesDir then
begin
if not CurrentCloud.getIncomingLinksListing(CurrentListing, CurrentIncomingInvitesListing) then
SetLastError(ERROR_PATH_NOT_FOUND); //одновременно получаем оба листинга, чтобы не перечитывать листинг инватов на каждый чих
end else begin //Нужно проверить, является ли открываемый объект каталогом - для файлов API вернёт листинг вышестоящего каталога, см. issue #174
if not CurrentCloud.getDirListing(RealPath.Path, CurrentListing) then
if not Assigned(CurrentCloud) then
begin
SetLastError(ERROR_PATH_NOT_FOUND);
end;
exit(INVALID_HANDLE_VALUE);
end;

if RealPath.isVirtual and not RealPath.isInAccountsList then //игнорим попытки получить листинги объектов вирутальных каталогов
begin
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_ACCESS_DENIED);
exit;
end;
if RealPath.trashDir then
begin
if not CurrentCloud.getTrashbinListing(CurrentListing) then
SetLastError(ERROR_PATH_NOT_FOUND);
end else if RealPath.sharedDir then
begin
if not CurrentCloud.getSharedLinksListing(CurrentListing) then
SetLastError(ERROR_PATH_NOT_FOUND); //that will be interpreted as symlinks later
end else if RealPath.invitesDir then
begin
if not CurrentCloud.getIncomingLinksListing(CurrentListing, CurrentIncomingInvitesListing) then
SetLastError(ERROR_PATH_NOT_FOUND); //одновременно получаем оба листинга, чтобы не перечитывать листинг инватов на каждый чих
end else begin //Нужно проверить, является ли открываемый объект каталогом - для файлов API вернёт листинг вышестоящего каталога, см. issue #174
if not CurrentCloud.getDirListing(RealPath.Path, CurrentListing) then
SetLastError(ERROR_PATH_NOT_FOUND);
end;

if CurrentCloud.IsPublicAccount then
CurrentItem := CurrentListing.FindByName(ExtractUniversalFileName(RealPath.Path))
else
CurrentItem := CurrentListing.FindByHomePath(RealPath.Path);
if RealPath.isVirtual and not RealPath.isInAccountsList then //игнорим попытки получить листинги объектов вирутальных каталогов
begin
SetLastError(ERROR_ACCESS_DENIED);
exit(INVALID_HANDLE_VALUE);
end;

if not(CurrentItem.isNone or CurrentItem.isDir) then
begin
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_ACCESS_DENIED);
exit;
end;
if CurrentCloud.IsPublicAccount then
CurrentItem := CurrentListing.FindByName(ExtractUniversalFileName(RealPath.Path))
else
CurrentItem := CurrentListing.FindByHomePath(RealPath.Path);

if (Length(CurrentListing) = 0) then
begin
FindData := GetFindDataEmptyDir(); //воркароунд бага с невозможностью входа в пустой каталог, см. http://www.ghisler.ch/board/viewtopic.php?t=42399
Result := FIND_NO_MORE_FILES;
SetLastError(ERROR_NO_MORE_FILES);
end else begin
if not(CurrentItem.isNone or CurrentItem.isDir) then
begin
SetLastError(ERROR_PATH_NOT_FOUND);
exit(INVALID_HANDLE_VALUE);
end;

FindData := CurrentListing[0].ToFindData(RealPath.sharedDir); //folders inside shared links directory must be displayed as symlinks
FileCounter := 1;
if RealPath.sharedDir then
Result := FIND_SHARED_LINKS
else
Result := FIND_OK;
if (Length(CurrentListing) = 0) then
begin
FindData := GetFindDataEmptyDir(); //воркароунд бага с невозможностью входа в пустой каталог, см. http://www.ghisler.ch/board/viewtopic.php?t=42399
Result := FIND_NO_MORE_FILES;
SetLastError(ERROR_NO_MORE_FILES);
end else begin

FindData := CurrentListing[0].ToFindData(RealPath.sharedDir); //folders inside shared links directory must be displayed as symlinks
FileCounter := 1;
if RealPath.sharedDir then
Result := FIND_SHARED_LINKS
else
Result := FIND_OK;
end;
end;
end;
end;
Expand Down

0 comments on commit 1f837fd

Please sign in to comment.