diff --git a/sdk/storage/azure-storage-blobs/CHANGELOG.md b/sdk/storage/azure-storage-blobs/CHANGELOG.md index af1282551..ef3d29057 100644 --- a/sdk/storage/azure-storage-blobs/CHANGELOG.md +++ b/sdk/storage/azure-storage-blobs/CHANGELOG.md @@ -6,6 +6,7 @@ - Added support for telemetry options. - Added `Azure::Storage::Blobs::PackageVersion`. +- Added `ShareFileClient::GetRangeListDiff`. ### Breaking Changes @@ -19,6 +20,7 @@ - Changed return type of `BlobContainerClient::GetProperties` to `BlobContainerProperties`. - Changed return type of `BlobContainerClient::GetAccessPolicy` to `BlobContainerAccessPolicy`. - Changed return type of `BlobClient::GetProperties` to `BlobProperties`. +- Removed `PreviousShareSnapshot` from `GetShareFileRangeListOptions`, use `ShareFileClient::GetRangeListDiff` instead. ### Other Changes and Improvements diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp index fc8c7d5dc..79ba22ef2 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp @@ -296,6 +296,19 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const GetShareFileRangeListOptions& options = GetShareFileRangeListOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; + /** + * @brief Gets the list of valid range from the file within specified range that have changed + * since previousShareSnapshot was taken. + * @param previousShareSnapshot Specifies the previous snapshot. + * @param context Context for cancelling long running operations. + * @return Azure::Response containing the valid + * ranges within the file for the specified range. + */ + Azure::Response GetRangeListDiff( + std::string previousShareSnapshot, + const GetShareFileRangeListOptions& options = GetShareFileRangeListOptions(), + const Azure::Core::Context& context = Azure::Core::Context()) const; + /** * @brief List open handles on the file. * @param options Optional parameters to list this file's open handles. diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp index 470c60c99..88a0ffd62 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp @@ -487,12 +487,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { */ Azure::Nullable Range; - /** - * @brief The previous snapshot parameter is an opaque DateTime value that, when present, - * specifies the previous snapshot. - */ - Azure::Nullable PreviousShareSnapshot; - /** * @brief The operation will only succeed if the access condition is met. */ diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index 9d6669fb1..e2ad572c6 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -563,7 +563,34 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } } - protocolLayerOptions.PrevShareSnapshot = options.PreviousShareSnapshot; + protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; + return _detail::ShareRestClient::File::GetRangeList( + m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); + } + + Azure::Response ShareFileClient::GetRangeListDiff( + std::string previousShareSnapshot, + const GetShareFileRangeListOptions& options, + const Azure::Core::Context& context) const + { + auto protocolLayerOptions = _detail::ShareRestClient::File::GetRangeListOptions(); + if (options.Range.HasValue()) + { + if (options.Range.GetValue().Length.HasValue()) + { + protocolLayerOptions.XMsRange = std::string("bytes=") + + std::to_string(options.Range.GetValue().Offset) + std::string("-") + + std::to_string(options.Range.GetValue().Offset + + options.Range.GetValue().Length.GetValue() - 1); + } + else + { + protocolLayerOptions.XMsRange = std::string("bytes=") + + std::to_string(options.Range.GetValue().Offset) + std::string("-"); + } + } + + protocolLayerOptions.PrevShareSnapshot = std::move(previousShareSnapshot); protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; return _detail::ShareRestClient::File::GetRangeList( m_shareFileUrl, *m_pipeline, context, protocolLayerOptions); diff --git a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp index aec1858c2..81fd6f3df 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp @@ -757,8 +757,7 @@ namespace Azure { namespace Storage { namespace Test { auto snapshot2 = m_shareClient->CreateSnapshot()->Snapshot; Files::Shares::Models::GetShareFileRangeListResult result; Files::Shares::GetShareFileRangeListOptions options; - options.PreviousShareSnapshot = snapshot1; - EXPECT_NO_THROW(result = fileClient.GetRangeList(options).ExtractValue()); + EXPECT_NO_THROW(result = fileClient.GetRangeListDiff(snapshot1, options).ExtractValue()); EXPECT_EQ(2U, result.Ranges.size()); EXPECT_EQ(0, result.Ranges[0].Offset); EXPECT_TRUE(result.Ranges[0].Length.HasValue()); @@ -768,8 +767,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(512, result.Ranges[1].Length.GetValue()); EXPECT_NO_THROW(fileClient.ClearRange(3096, 2048)); auto snapshot3 = m_shareClient->CreateSnapshot()->Snapshot; - options.PreviousShareSnapshot = snapshot1; - EXPECT_NO_THROW(result = fileClient.GetRangeList(options).ExtractValue()); + EXPECT_NO_THROW(result = fileClient.GetRangeListDiff(snapshot1, options).ExtractValue()); EXPECT_EQ(4U, result.Ranges.size()); EXPECT_EQ(0, result.Ranges[0].Offset); EXPECT_TRUE(result.Ranges[0].Length.HasValue());