diff --git a/cloud/cloud_file_system.cc b/cloud/cloud_file_system.cc index 0d55313577e8..3896fc6021d4 100644 --- a/cloud/cloud_file_system.cc +++ b/cloud/cloud_file_system.cc @@ -125,6 +125,14 @@ BucketOptions::BucketOptions() { "ROCKSDB_CLOUD_TEST_REGION", "ROCKSDB_CLOUD_REGION", ®ion_); } +void BucketOptions::SetName() { + if (bucket_.empty()) { + name_.clear(); + } else { + name_ = prefix_ + bucket_; + } +} + void BucketOptions::SetBucketName(const std::string& bucket, const std::string& prefix) { if (!prefix.empty()) { @@ -132,11 +140,12 @@ void BucketOptions::SetBucketName(const std::string& bucket, } bucket_ = bucket; - if (bucket_.empty()) { - name_.clear(); - } else { - name_ = prefix_ + bucket_; - } + SetName(); +} + +void BucketOptions::SetPrefix(std::string prefix) { + prefix_ = std::move(prefix); + SetName(); } // Initializes the bucket properties diff --git a/include/rocksdb/cloud/cloud_file_system.h b/include/rocksdb/cloud/cloud_file_system.h index 46d72b4c7c06..31f8dc848040 100644 --- a/include/rocksdb/cloud/cloud_file_system.h +++ b/include/rocksdb/cloud/cloud_file_system.h @@ -129,12 +129,16 @@ class BucketOptions { std::string object_; // The object path for the bucket std::string region_; // The region for the bucket std::string name_; // The name of the bucket (prefix_ + bucket_) + + void SetName(); + public: BucketOptions(); // Sets the name of the bucket to be the new bucket name. // If prefix is specified, the new bucket name will be [prefix][bucket] // If no prefix is specified, the bucket name will use the existing prefix void SetBucketName(const std::string& bucket, const std::string& prefix = ""); + void SetBucketPrefix(std::string prefix); const std::string& GetBucketPrefix() const { return prefix_; } const std::string& GetBucketName(bool full = true) const { if (full) {