block id list now is a vector of strings (#1034)
* block id list now is a vector of strings * changelog
This commit is contained in:
parent
cc75233a54
commit
f378a3a467
@ -36,6 +36,7 @@
|
||||
- `ContainerAccessConditions ` to `BlobContainerAccessConditions`
|
||||
- `ListContainersSegmentResult` to `ListBlobContainersSegmentResult`
|
||||
- `ListContainersSegmentOptions` to `ListBlobContainersSegmentOptions`
|
||||
* API signature for CommitBlockList has changed. `BlockType` doesn't need to be specified anymore.
|
||||
|
||||
## 12.0.0-beta.5 (2020-11-13)
|
||||
|
||||
|
||||
@ -201,7 +201,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
* @return A CommitBlobBlockListResult describing the state of the updated block blob.
|
||||
*/
|
||||
Azure::Core::Response<Models::CommitBlockListResult> CommitBlockList(
|
||||
const std::vector<std::pair<Models::BlockType, std::string>>& blockIds,
|
||||
const std::vector<std::string>& blockIds,
|
||||
const CommitBlockListOptions& options = CommitBlockListOptions()) const;
|
||||
|
||||
/**
|
||||
|
||||
@ -135,7 +135,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return Upload(&contentStream, uploadBlockBlobOptions);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Models::BlockType, std::string>> blockIds;
|
||||
std::vector<std::string> blockIds;
|
||||
auto getBlockId = [](int64_t id) {
|
||||
constexpr std::size_t BlockIdLength = 64;
|
||||
std::string blockId = std::to_string(id);
|
||||
@ -159,8 +159,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
for (std::size_t i = 0; i < blockIds.size(); ++i)
|
||||
{
|
||||
blockIds[i].first = Models::BlockType::Uncommitted;
|
||||
blockIds[i].second = getBlockId(static_cast<int64_t>(i));
|
||||
blockIds[i] = getBlockId(static_cast<int64_t>(i));
|
||||
}
|
||||
CommitBlockListOptions commitBlockListOptions;
|
||||
commitBlockListOptions.Context = options.Context;
|
||||
@ -217,7 +216,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
return Upload(&contentStream, uploadBlockBlobOptions);
|
||||
}
|
||||
|
||||
std::vector<std::pair<Models::BlockType, std::string>> blockIds;
|
||||
std::vector<std::string> blockIds;
|
||||
auto getBlockId = [](int64_t id) {
|
||||
constexpr std::size_t BlockIdLength = 64;
|
||||
std::string blockId = std::to_string(id);
|
||||
@ -241,8 +240,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
|
||||
for (std::size_t i = 0; i < blockIds.size(); ++i)
|
||||
{
|
||||
blockIds[i].first = Models::BlockType::Uncommitted;
|
||||
blockIds[i].second = getBlockId(static_cast<int64_t>(i));
|
||||
blockIds[i] = getBlockId(static_cast<int64_t>(i));
|
||||
}
|
||||
CommitBlockListOptions commitBlockListOptions;
|
||||
commitBlockListOptions.Context = options.Context;
|
||||
@ -325,11 +323,15 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
}
|
||||
|
||||
Azure::Core::Response<Models::CommitBlockListResult> BlockBlobClient::CommitBlockList(
|
||||
const std::vector<std::pair<Models::BlockType, std::string>>& blockIds,
|
||||
const std::vector<std::string>& blockIds,
|
||||
const CommitBlockListOptions& options) const
|
||||
{
|
||||
Details::BlobRestClient::BlockBlob::CommitBlockListOptions protocolLayerOptions;
|
||||
protocolLayerOptions.BlockList = blockIds;
|
||||
protocolLayerOptions.BlockList.reserve(blockIds.size());
|
||||
for (const auto& id : blockIds)
|
||||
{
|
||||
protocolLayerOptions.BlockList.emplace_back(std::make_pair(Models::BlockType::Latest, id));
|
||||
}
|
||||
protocolLayerOptions.HttpHeaders = options.HttpHeaders;
|
||||
protocolLayerOptions.Metadata = options.Metadata;
|
||||
protocolLayerOptions.Tier = options.Tier;
|
||||
|
||||
@ -528,9 +528,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
bodyStream.Rewind();
|
||||
EXPECT_NO_THROW(blockBlob.StageBlock(blockId1, &bodyStream));
|
||||
EXPECT_NO_THROW(blockBlob.StageBlockFromUri(blockId2, copySourceBlob.GetUrl() + GetSas()));
|
||||
EXPECT_NO_THROW(blockBlob.CommitBlockList(
|
||||
{{Blobs::Models::BlockType::Uncommitted, blockId1},
|
||||
{Blobs::Models::BlockType::Uncommitted, blockId2}}));
|
||||
EXPECT_NO_THROW(blockBlob.CommitBlockList({blockId1, blockId2}));
|
||||
EXPECT_THROW(blockBlob.SetAccessTier(Blobs::Models::AccessTier::Cool), StorageException);
|
||||
|
||||
auto appendBlobClientWithoutEncryptionKey
|
||||
@ -1029,8 +1027,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
|
||||
{
|
||||
std::string blockId = Base64Encode("1");
|
||||
std::vector<std::pair<Blobs::Models::BlockType, std::string>> blockIds
|
||||
= {{Blobs::Models::BlockType::Uncommitted, blockId}};
|
||||
std::vector<std::string> blockIds = {blockId};
|
||||
content.Rewind();
|
||||
blockBlobClient.StageBlock(blockId, &content);
|
||||
|
||||
|
||||
@ -276,8 +276,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
Azure::Storage::Blobs::CommitBlockListOptions options;
|
||||
options.HttpHeaders = m_blobUploadOptions.HttpHeaders;
|
||||
options.Metadata = m_blobUploadOptions.Metadata;
|
||||
auto blobContentInfo = blockBlobClient.CommitBlockList(
|
||||
{{Azure::Storage::Blobs::Models::BlockType::Uncommitted, blockId1}}, options);
|
||||
auto blobContentInfo = blockBlobClient.CommitBlockList({blockId1}, options);
|
||||
EXPECT_FALSE(blobContentInfo->ETag.empty());
|
||||
EXPECT_FALSE(blobContentInfo->LastModified.empty());
|
||||
EXPECT_TRUE(blobContentInfo->VersionId.HasValue());
|
||||
@ -303,9 +302,7 @@ namespace Azure { namespace Storage { namespace Test {
|
||||
EXPECT_EQ(res->UncommittedBlocks[0].Name, blockId2);
|
||||
EXPECT_EQ(res->UncommittedBlocks[0].Size, static_cast<int64_t>(m_blobContent.size()));
|
||||
|
||||
blockBlobClient.CommitBlockList(
|
||||
{{Azure::Storage::Blobs::Models::BlockType::Committed, blockId1},
|
||||
{Azure::Storage::Blobs::Models::BlockType::Uncommitted, blockId2}});
|
||||
blockBlobClient.CommitBlockList({blockId1, blockId2});
|
||||
res = blockBlobClient.GetBlockList(options2);
|
||||
EXPECT_EQ(
|
||||
res->ContentLength, static_cast<int64_t>(block1Content.size() + m_blobContent.size()));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user