Browse Source

Bug 1946: Hang when S3 server returns a truncated listing with folders only (2nd)

(cherry picked from commit 4074788fe46289b9aee9115d92ece163d73b3437)

Source commit: fcaf8e7e837c0e83fb1dd097b2df31a1519d152b
Martin Prikryl 4 years ago
parent
commit
595281e983
1 changed files with 2 additions and 2 deletions
  1. 2 2
      source/core/S3FileSystem.cpp

+ 2 - 2
source/core/S3FileSystem.cpp

@@ -877,6 +877,7 @@ void TS3FileSystem::ReadDirectoryInternal(
   const UnicodeString & APath, TRemoteFileList * FileList, int MaxKeys, const UnicodeString & FileName)
 {
   UnicodeString Path = UnixExcludeTrailingBackslash(AbsolutePath(APath, false));
+  int AMaxKeys = (MaxKeys == -1) ? 1 : MaxKeys;
   if (IsUnixRootPath(Path))
   {
     DebugAssert(FileList != NULL);
@@ -901,7 +902,6 @@ void TS3FileSystem::ReadDirectoryInternal(
         MaxKeys = 0;
       }
 
-      int AMaxKeys = (MaxKeys == -1) ? 1 : MaxKeys;
       S3_list_service(
         FLibS3Protocol, FAccessKeyId.c_str(), FSecretAccessKey.c_str(), FSecurityToken, (FHostName + FPortSuffix).c_str(),
         StrToS3(FAuthRegion), AMaxKeys, FRequestContext, FTimeout, &ListServiceHandler, &Data);
@@ -928,7 +928,7 @@ void TS3FileSystem::ReadDirectoryInternal(
 
     do
     {
-      DoListBucket(Prefix, FileList, MaxKeys, BucketContext, Data);
+      DoListBucket(Prefix, FileList, AMaxKeys, BucketContext, Data);
       CheckLibS3Error(Data);
 
       Continue = false;