@@ -1079,8 +1079,9 @@ function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDD
1079
1079
1080
1080
if SkipListDelete or SkipListRenMov or RenMovAborted then
1081
1081
begin
1082
- SetLastError(ERROR_NO_MORE_FILES);
1083
- exit(INVALID_HANDLE_VALUE);
1082
+ Result := INVALID_HANDLE_VALUE;
1083
+ SetLastError(ERROR_NO_MORE_FILES); // in some unpredictable situations causes unintentional exit (#308)
1084
+ exit;
1084
1085
end ;
1085
1086
1086
1087
// Result := FIND_NO_MORE_FILES;
@@ -1094,23 +1095,26 @@ function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDD
1094
1095
FileCounter := 1 ;
1095
1096
Result := FIND_ROOT_DIRECTORY;
1096
1097
end else begin
1097
- Result := INVALID_HANDLE_VALUE; // Нельзя использовать exit
1098
- SetLastError(ERROR_NO_MORE_FILES);
1098
+ Result := INVALID_HANDLE_VALUE;
1099
+ SetLastError(ERROR_NO_MORE_FILES); // in some unpredictable situations causes unintentional exit (#308)
1100
+ exit;
1099
1101
end ;
1100
1102
end else begin
1101
1103
RealPath.FromPath(GlobalPath);
1102
1104
CurrentCloud := ConnectionManager.Get(RealPath.account, getResult);
1103
1105
1104
1106
if getResult <> CLOUD_OPERATION_OK then
1105
1107
begin
1108
+ Result := INVALID_HANDLE_VALUE;
1106
1109
SetLastError(ERROR_ACCESS_DENIED);
1107
- exit(INVALID_HANDLE_VALUE) ;
1110
+ exit;
1108
1111
end ;
1109
1112
1110
1113
if not Assigned(CurrentCloud) then
1111
1114
begin
1115
+ Result := INVALID_HANDLE_VALUE;
1112
1116
SetLastError(ERROR_PATH_NOT_FOUND);
1113
- exit(INVALID_HANDLE_VALUE) ;
1117
+ exit;
1114
1118
end ;
1115
1119
1116
1120
if RealPath.trashDir then
@@ -1132,8 +1136,9 @@ function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDD
1132
1136
1133
1137
if RealPath.isVirtual and not RealPath.isInAccountsList then // игнорим попытки получить листинги объектов вирутальных каталогов
1134
1138
begin
1139
+ Result := INVALID_HANDLE_VALUE;
1135
1140
SetLastError(ERROR_ACCESS_DENIED);
1136
- exit(INVALID_HANDLE_VALUE) ;
1141
+ exit;
1137
1142
end ;
1138
1143
1139
1144
if CurrentCloud.IsPublicAccount then
@@ -1143,8 +1148,9 @@ function TMailRuCloudWFX.FsFindFirst(Path: WideString; var FindData: tWIN32FINDD
1143
1148
1144
1149
if not (CurrentItem.isNone or CurrentItem.isDir) then
1145
1150
begin
1146
- SetLastError(ERROR_PATH_NOT_FOUND);
1147
- exit(INVALID_HANDLE_VALUE);
1151
+ Result := INVALID_HANDLE_VALUE;
1152
+ SetLastError(ERROR_ACCESS_DENIED);
1153
+ exit;
1148
1154
end ;
1149
1155
1150
1156
if (Length(CurrentListing) = 0 ) then
0 commit comments