mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix ListObject in azure client
This commit is contained in:
parent
bf4caa06c1
commit
b3b9d65c04
@ -25,6 +25,7 @@ namespace DB
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
namespace AzureBlobStorage
|
||||
@ -76,11 +77,28 @@ BlockBlobClient ContainerClientWrapper::GetBlockBlobClient(const String & blob_n
|
||||
return client.GetBlockBlobClient(blob_prefix / blob_name);
|
||||
}
|
||||
|
||||
BlobContainerPropertiesRespones ContainerClientWrapper::GetProperties() const
|
||||
{
|
||||
return client.GetProperties();
|
||||
}
|
||||
|
||||
ListBlobsPagedResponse ContainerClientWrapper::ListBlobs(const ListBlobsOptions & options) const
|
||||
{
|
||||
auto new_options = options;
|
||||
new_options.Prefix = blob_prefix / options.Prefix.ValueOr("");
|
||||
return client.ListBlobs(new_options);
|
||||
|
||||
auto response = client.ListBlobs(new_options);
|
||||
auto blob_prefix_str = blob_prefix.string() + "/";
|
||||
|
||||
for (auto & blob : response.Blobs)
|
||||
{
|
||||
if (!blob.Name.starts_with(blob_prefix_str))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected prefix '{}' in blob name '{}'", blob_prefix_str, blob.Name);
|
||||
|
||||
blob.Name = blob.Name.substr(blob_prefix_str.size());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
bool ContainerClientWrapper::IsClientForDisk() const
|
||||
@ -258,7 +276,7 @@ void processURL(const String & url, const String & container_name, Endpoint & en
|
||||
static bool containerExists(const ContainerClient & client)
|
||||
{
|
||||
ProfileEvents::increment(ProfileEvents::AzureGetProperties);
|
||||
if (client.GetClickhouseOptions().IsClientForDisk)
|
||||
if (client.IsClientForDisk())
|
||||
ProfileEvents::increment(ProfileEvents::DiskAzureGetProperties);
|
||||
|
||||
try
|
||||
|
@ -100,6 +100,7 @@ using RawContainerClient = Azure::Storage::Blobs::BlobContainerClient;
|
||||
|
||||
using Azure::Storage::Blobs::ListBlobsOptions;
|
||||
using Azure::Storage::Blobs::ListBlobsPagedResponse;
|
||||
using BlobContainerPropertiesRespones = Azure::Response<Azure::Storage::Blobs::Models::BlobContainerProperties>;
|
||||
|
||||
/// A wrapper for ContainerClient that correctly handles the prefix of blobs.
|
||||
/// See AzureBlobStorageEndpoint and processAzureBlobStorageEndpoint for details.
|
||||
@ -111,6 +112,7 @@ public:
|
||||
bool IsClientForDisk() const;
|
||||
BlobClient GetBlobClient(const String & blob_name) const;
|
||||
BlockBlobClient GetBlockBlobClient(const String & blob_name) const;
|
||||
BlobContainerPropertiesRespones GetProperties() const;
|
||||
ListBlobsPagedResponse ListBlobs(const ListBlobsOptions & options) const;
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user