From e0d717a0d30a0ed2d758ff2d02979c4370e126dc Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Wed, 14 Oct 2020 13:23:40 +0800 Subject: [PATCH] revert non-overwriting changes (#773) --- .../inc/azure/storage/blobs/blob_options.hpp | 15 --------------- .../src/append_blob_client.cpp | 4 ---- .../src/block_blob_client.cpp | 6 ------ .../azure-storage-blobs/src/page_blob_client.cpp | 4 ---- .../test/append_blob_client_test.cpp | 11 ----------- .../test/blob_container_client_test.cpp | 3 --- .../test/block_blob_client_test.cpp | 16 ---------------- .../test/page_blob_client_test.cpp | 11 ----------- 8 files changed, 70 deletions(-) diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp index 655113621..94783c3a1 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_options.hpp @@ -930,11 +930,6 @@ namespace Azure { namespace Storage { namespace Blobs { */ Azure::Core::Context Context; - /** - * @brief Whether the upload should overwrite any existing blobs. - */ - bool Overwrite = false; - /** * @brief An MD5 hash of the blob content. This hash is used to verify the integrity of * the blob during transport. When this header is specified, the storage service checks the hash @@ -1149,11 +1144,6 @@ namespace Azure { namespace Storage { namespace Blobs { */ Azure::Core::Context Context; - /** - * @brief Whether the existing blob should be deleted and recreated. - */ - bool Overwrite = false; - /** * @brief The standard HTTP header system properties to set. */ @@ -1267,11 +1257,6 @@ namespace Azure { namespace Storage { namespace Blobs { */ Azure::Core::Context Context; - /** - * @brief Whether the existing blob should be deleted and recreated. - */ - bool Overwrite = false; - /** * @brief The sequence number is a user-controlled value that you can use to track requests. The * value of the sequence number must be between 0 and 2^63 - 1. diff --git a/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp index aa3a62f25..f1fb20ca7 100644 --- a/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/append_blob_client.cpp @@ -85,10 +85,6 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch; protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch; - if (!options.Overwrite) - { - protocolLayerOptions.IfNoneMatch = c_ETagWildcard; - } protocolLayerOptions.IfTags = options.AccessConditions.TagConditions; if (m_customerProvidedKey.HasValue()) { diff --git a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp index 05678dbdb..cecced55e 100644 --- a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp @@ -92,10 +92,6 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch; protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch; - if (!options.Overwrite) - { - protocolLayerOptions.IfNoneMatch = c_ETagWildcard; - } protocolLayerOptions.IfTags = options.AccessConditions.TagConditions; if (m_customerProvidedKey.HasValue()) { @@ -137,7 +133,6 @@ namespace Azure { namespace Storage { namespace Blobs { uploadBlockBlobOptions.HttpHeaders = options.HttpHeaders; uploadBlockBlobOptions.Metadata = options.Metadata; uploadBlockBlobOptions.Tier = options.Tier; - uploadBlockBlobOptions.Overwrite = true; return Upload(&contentStream, uploadBlockBlobOptions); } @@ -219,7 +214,6 @@ namespace Azure { namespace Storage { namespace Blobs { uploadBlockBlobOptions.HttpHeaders = options.HttpHeaders; uploadBlockBlobOptions.Metadata = options.Metadata; uploadBlockBlobOptions.Tier = options.Tier; - uploadBlockBlobOptions.Overwrite = true; return Upload(&contentStream, uploadBlockBlobOptions); } diff --git a/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp index c20036031..d9bcd4189 100644 --- a/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/page_blob_client.cpp @@ -89,10 +89,6 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; protocolLayerOptions.IfMatch = options.AccessConditions.IfMatch; protocolLayerOptions.IfNoneMatch = options.AccessConditions.IfNoneMatch; - if (!options.Overwrite) - { - protocolLayerOptions.IfNoneMatch = c_ETagWildcard; - } protocolLayerOptions.IfTags = options.AccessConditions.TagConditions; if (m_customerProvidedKey.HasValue()) { diff --git a/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp index 24d2cd7f2..8d36dd584 100644 --- a/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/append_blob_client_test.cpp @@ -330,15 +330,4 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_TRUE(getPropertiesResult->IsSealed.GetValue()); } - TEST_F(AppendBlobClientTest, Overwrite) - { - std::string blobName = RandomString(); - auto blobClient = m_blobContainerClient->GetAppendBlobClient(blobName); - EXPECT_NO_THROW(blobClient.Create()); - EXPECT_THROW(blobClient.Create(), StorageError); - Blobs::CreateAppendBlobOptions options; - options.Overwrite = true; - EXPECT_NO_THROW(blobClient.Create(options)); - } - }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp b/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp index d98d21bd5..c2fb5709a 100644 --- a/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/blob_container_client_test.cpp @@ -883,7 +883,6 @@ namespace Azure { namespace Storage { namespace Test { options.AccessConditions.TagConditions = failWhereExpression; EXPECT_THROW(appendBlobClient.Create(options), StorageError); options.AccessConditions.TagConditions = successWhereExpression; - options.Overwrite = true; EXPECT_NO_THROW(appendBlobClient.Create(options)); appendBlobClient.SetTags(tags); } @@ -959,7 +958,6 @@ namespace Azure { namespace Storage { namespace Test { options.AccessConditions.TagConditions = failWhereExpression; EXPECT_THROW(pageBlobClient.Create(contentSize, options), StorageError); options.AccessConditions.TagConditions = successWhereExpression; - options.Overwrite = true; EXPECT_NO_THROW(pageBlobClient.Create(contentSize, options)); pageBlobClient.SetTags(tags); @@ -1021,7 +1019,6 @@ namespace Azure { namespace Storage { namespace Test { content.Rewind(); EXPECT_THROW(blockBlobClient.Upload(&content, options), StorageError); options.AccessConditions.TagConditions = successWhereExpression; - options.Overwrite = true; content.Rewind(); EXPECT_NO_THROW(blockBlobClient.Upload(&content, options)); blockBlobClient.SetTags(tags); diff --git a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp index 556477ba1..4ad01ebb1 100644 --- a/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/block_blob_client_test.cpp @@ -759,20 +759,4 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_TRUE(exceptionCaught); } - TEST_F(BlockBlobClientTest, Overwrite) - { - std::string blobName = RandomString(); - std::vector blobContent(1); - auto blobContentStream - = Azure::Core::Http::MemoryBodyStream(m_blobContent.data(), m_blobContent.size()); - auto blobClient = m_blobContainerClient->GetBlockBlobClient(blobName); - EXPECT_NO_THROW(blobClient.Upload(&blobContentStream)); - blobContentStream.Rewind(); - EXPECT_THROW(blobClient.Upload(&blobContentStream), StorageError); - blobContentStream.Rewind(); - Blobs::UploadBlockBlobOptions options; - options.Overwrite = true; - EXPECT_NO_THROW(blobClient.Upload(&blobContentStream, options)); - } - }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp index a11909876..a88b87235 100644 --- a/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/page_blob_client_test.cpp @@ -251,15 +251,4 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_THROW(pageBlobClient.UploadPages(0, &pageContent, options), StorageError); } - TEST_F(PageBlobClientTest, Overwrite) - { - std::string blobName = RandomString(); - auto blobClient = m_blobContainerClient->GetPageBlobClient(blobName); - EXPECT_NO_THROW(blobClient.Create(1024)); - EXPECT_THROW(blobClient.Create(1024), StorageError); - Blobs::CreatePageBlobOptions options; - options.Overwrite = true; - EXPECT_NO_THROW(blobClient.Create(1024, options)); - } - }}} // namespace Azure::Storage::Test