GetRangeListDiff (#1915)
This commit is contained in:
parent
ca1692e375
commit
35b39f7cb1
@ -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
|
||||
|
||||
|
||||
@ -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<Models::GetShareFileRangeListResult> containing the valid
|
||||
* ranges within the file for the specified range.
|
||||
*/
|
||||
Azure::Response<Models::GetShareFileRangeListResult> 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.
|
||||
|
||||
@ -487,12 +487,6 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
|
||||
*/
|
||||
Azure::Nullable<Core::Http::HttpRange> Range;
|
||||
|
||||
/**
|
||||
* @brief The previous snapshot parameter is an opaque DateTime value that, when present,
|
||||
* specifies the previous snapshot.
|
||||
*/
|
||||
Azure::Nullable<std::string> PreviousShareSnapshot;
|
||||
|
||||
/**
|
||||
* @brief The operation will only succeed if the access condition is met.
|
||||
*/
|
||||
|
||||
@ -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<Models::GetShareFileRangeListResult> 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);
|
||||
|
||||
@ -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());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user