Преглед изворни кода

Bug fix: Hidden session settings S3DefaultRegion to create an S3 bucket in a non-default region was not working

Source commit: 0223792971b656534792aef7fa07a1edd1c8d4d9
Martin Prikryl пре 7 година
родитељ
комит
89a92bc649
3 измењених фајлова са 16 додато и 4 уклоњено
  1. 11 3
      source/core/S3FileSystem.cpp
  2. 1 1
      source/core/SessionData.cpp
  3. 4 0
      source/core/SessionInfo.cpp

+ 11 - 3
source/core/S3FileSystem.cpp

@@ -1024,11 +1024,19 @@ void __fastcall TS3FileSystem::CreateDirectory(const UnicodeString ADirName)
   {
     S3ResponseHandler ResponseHandler = CreateResponseHandler();
 
-    // Not using GetBucketContext here, as the bucket does not exist, so we have to explicitly use S3DefaultRegion
+    // Not using GetBucketContext here, as the bucket does not exist
+
+    UTF8String RegionBuf;
+    char * Region = NULL;
+    if (FTerminal->SessionData->S3DefaultRegion != S3LibDefaultRegion())
+    {
+      RegionBuf = UTF8String(FTerminal->SessionData->S3DefaultRegion);
+      Region = RegionBuf.c_str();
+    }
+
     S3_create_bucket(
       FLibS3Protocol, FAccessKeyId.c_str(), FSecretAccessKey.c_str(), NULL, FHostName.c_str(), StrToS3(BucketName),
-      StrToS3(FTerminal->SessionData->S3DefaultRegion), S3CannedAclPrivate, NULL, FRequestContext, FTimeout,
-      &ResponseHandler, &Data);
+      StrToS3(S3LibDefaultRegion()), S3CannedAclPrivate, Region, FRequestContext, FTimeout, &ResponseHandler, &Data);
   }
   else
   {

+ 1 - 1
source/core/SessionData.cpp

@@ -638,7 +638,7 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool PuttyI
   NotUtf = TAutoSwitch(Storage->ReadInteger(L"Utf", Storage->ReadInteger(L"SFTPUtfBug", NotUtf)));
   InternalEditorEncoding = Storage->ReadInteger(L"InternalEditorEncoding", InternalEditorEncoding);
 
-  S3DefaultRegion = Storage->ReadString(L"Utf", S3DefaultRegion);
+  S3DefaultRegion = Storage->ReadString(L"S3DefaultRegion", S3DefaultRegion);
 
   // PuTTY defaults to TcpNoDelay, but the psftp/pscp ignores this preference, and always set this to off (what is our default too)
   if (!PuttyImport)

+ 4 - 0
source/core/SessionInfo.cpp

@@ -1264,6 +1264,10 @@ void __fastcall TSessionLog::DoAddStartupInfo(TSessionData * Data)
     {
       FtpsOn = (Data->Ftps != ftpsNone);
       ADF(L"HTTPS: %s", (BooleanToEngStr(FtpsOn)));
+      if (!Data->S3DefaultRegion.IsEmpty())
+      {
+        ADF(L"S3: Default region: %s", (Data->S3DefaultRegion));
+      }
     }
     if (FtpsOn)
     {