Skip to content

Commit 8f31c38

Browse files
committed
issue #309
Changed the way how directory listings are skipped when necessary (not sure, if it is a good solution)
1 parent a997396 commit 8f31c38

File tree

1 file changed

+73
-73
lines changed

1 file changed

+73
-73
lines changed

models/wfx/MailRuCloudWFX.pas

+73-73
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ function TMailRuCloudWFX.FsFindClose(Hdl: THandle): Integer;
10571057
end;
10581058

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

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

10801079
if SkipListDelete or SkipListRenMov or RenMovAborted then
10811080
begin
1081+
CurrentListing := [];
10821082
SetLastError(ERROR_NO_MORE_FILES);
1083-
exit(INVALID_HANDLE_VALUE);
1084-
end;
1085-
1086-
//Result := FIND_NO_MORE_FILES;
1087-
GlobalPath := Path;
1088-
if GlobalPath = '\' then
1089-
begin //список соединений
1090-
Accounts := AccountSettings.GetAccountsList([ATPrivate, ATPublic], SettingsManager.Settings.EnabledVirtualTypes);
1091-
if (Accounts.Count > 0) then
1092-
begin
1093-
FindData := GetFindDataEmptyDir(Accounts[0]);
1094-
FileCounter := 1;
1095-
Result := FIND_ROOT_DIRECTORY;
1096-
end else begin
1097-
Result := INVALID_HANDLE_VALUE; //Нельзя использовать exit
1098-
SetLastError(ERROR_NO_MORE_FILES);
1099-
end;
1083+
Result := FIND_NO_MORE_FILES;
11001084
end else begin
1101-
RealPath.FromPath(GlobalPath);
1102-
CurrentCloud := ConnectionManager.Get(RealPath.account, getResult);
1103-
1104-
if getResult <> CLOUD_OPERATION_OK then
1105-
begin
1106-
SetLastError(ERROR_ACCESS_DENIED);
1107-
exit(INVALID_HANDLE_VALUE);
1108-
end;
1085+
//Result := FIND_NO_MORE_FILES;
1086+
GlobalPath := Path;
1087+
if GlobalPath = '\' then
1088+
begin //список соединений
1089+
Accounts := AccountSettings.GetAccountsList([ATPrivate, ATPublic], SettingsManager.Settings.EnabledVirtualTypes);
1090+
if (Accounts.Count > 0) then
1091+
begin
1092+
FindData := GetFindDataEmptyDir(Accounts[0]);
1093+
FileCounter := 1;
1094+
Result := FIND_ROOT_DIRECTORY;
1095+
end else begin
1096+
Result := INVALID_HANDLE_VALUE; //Нельзя использовать exit
1097+
SetLastError(ERROR_NO_MORE_FILES);
1098+
end;
1099+
end else begin
1100+
RealPath.FromPath(GlobalPath);
1101+
CurrentCloud := ConnectionManager.Get(RealPath.account, getResult);
11091102

1110-
if not Assigned(CurrentCloud) then
1111-
begin
1112-
SetLastError(ERROR_PATH_NOT_FOUND);
1113-
exit(INVALID_HANDLE_VALUE);
1114-
end;
1103+
if getResult <> CLOUD_OPERATION_OK then
1104+
begin
1105+
SetLastError(ERROR_ACCESS_DENIED);
1106+
exit(INVALID_HANDLE_VALUE);
1107+
end;
11151108

1116-
if RealPath.trashDir then
1117-
begin
1118-
if not CurrentCloud.getTrashbinListing(CurrentListing) then
1119-
SetLastError(ERROR_PATH_NOT_FOUND);
1120-
end else if RealPath.sharedDir then
1121-
begin
1122-
if not CurrentCloud.getSharedLinksListing(CurrentListing) then
1123-
SetLastError(ERROR_PATH_NOT_FOUND); //that will be interpreted as symlinks later
1124-
end else if RealPath.invitesDir then
1125-
begin
1126-
if not CurrentCloud.getIncomingLinksListing(CurrentListing, CurrentIncomingInvitesListing) then
1127-
SetLastError(ERROR_PATH_NOT_FOUND); //одновременно получаем оба листинга, чтобы не перечитывать листинг инватов на каждый чих
1128-
end else begin //Нужно проверить, является ли открываемый объект каталогом - для файлов API вернёт листинг вышестоящего каталога, см. issue #174
1129-
if not CurrentCloud.getDirListing(RealPath.Path, CurrentListing) then
1109+
if not Assigned(CurrentCloud) then
1110+
begin
11301111
SetLastError(ERROR_PATH_NOT_FOUND);
1131-
end;
1112+
exit(INVALID_HANDLE_VALUE);
1113+
end;
11321114

1133-
if RealPath.isVirtual and not RealPath.isInAccountsList then //игнорим попытки получить листинги объектов вирутальных каталогов
1134-
begin
1135-
SetLastError(ERROR_ACCESS_DENIED);
1136-
exit(INVALID_HANDLE_VALUE);
1137-
end;
1115+
if RealPath.trashDir then
1116+
begin
1117+
if not CurrentCloud.getTrashbinListing(CurrentListing) then
1118+
SetLastError(ERROR_PATH_NOT_FOUND);
1119+
end else if RealPath.sharedDir then
1120+
begin
1121+
if not CurrentCloud.getSharedLinksListing(CurrentListing) then
1122+
SetLastError(ERROR_PATH_NOT_FOUND); //that will be interpreted as symlinks later
1123+
end else if RealPath.invitesDir then
1124+
begin
1125+
if not CurrentCloud.getIncomingLinksListing(CurrentListing, CurrentIncomingInvitesListing) then
1126+
SetLastError(ERROR_PATH_NOT_FOUND); //одновременно получаем оба листинга, чтобы не перечитывать листинг инватов на каждый чих
1127+
end else begin //Нужно проверить, является ли открываемый объект каталогом - для файлов API вернёт листинг вышестоящего каталога, см. issue #174
1128+
if not CurrentCloud.getDirListing(RealPath.Path, CurrentListing) then
1129+
SetLastError(ERROR_PATH_NOT_FOUND);
1130+
end;
11381131

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

1144-
if not(CurrentItem.isNone or CurrentItem.isDir) then
1145-
begin
1146-
SetLastError(ERROR_PATH_NOT_FOUND);
1147-
exit(INVALID_HANDLE_VALUE);
1148-
end;
1138+
if CurrentCloud.IsPublicAccount then
1139+
CurrentItem := CurrentListing.FindByName(ExtractUniversalFileName(RealPath.Path))
1140+
else
1141+
CurrentItem := CurrentListing.FindByHomePath(RealPath.Path);
11491142

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

1157-
FindData := CurrentListing[0].ToFindData(RealPath.sharedDir); //folders inside shared links directory must be displayed as symlinks
1158-
FileCounter := 1;
1159-
if RealPath.sharedDir then
1160-
Result := FIND_SHARED_LINKS
1161-
else
1162-
Result := FIND_OK;
1149+
if (Length(CurrentListing) = 0) then
1150+
begin
1151+
FindData := GetFindDataEmptyDir(); //воркароунд бага с невозможностью входа в пустой каталог, см. http://www.ghisler.ch/board/viewtopic.php?t=42399
1152+
Result := FIND_NO_MORE_FILES;
1153+
SetLastError(ERROR_NO_MORE_FILES);
1154+
end else begin
1155+
1156+
FindData := CurrentListing[0].ToFindData(RealPath.sharedDir); //folders inside shared links directory must be displayed as symlinks
1157+
FileCounter := 1;
1158+
if RealPath.sharedDir then
1159+
Result := FIND_SHARED_LINKS
1160+
else
1161+
Result := FIND_OK;
1162+
end;
11631163
end;
11641164
end;
11651165
end;

0 commit comments

Comments
 (0)