Skip to content

Commit e62da2f

Browse files
authored
Storage/STG93 Add Rename Support to List Ranges (Azure#5266)
* add rename support * reset swagger url * update
1 parent 9a25292 commit e62da2f

File tree

7 files changed

+104
-51
lines changed

7 files changed

+104
-51
lines changed

sdk/storage/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "cpp",
44
"TagPrefix": "cpp/storage",
5-
"Tag": "cpp/storage_d89dcd9127"
5+
"Tag": "cpp/storage_9093786628"
66
}

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
3131
/**
3232
* The version used for the operations to Azure storage services.
3333
*/
34-
constexpr static const char* ApiVersion = "2024-02-04";
34+
constexpr static const char* ApiVersion = "2024-05-04";
3535
} // namespace _detail
3636
namespace Models {
3737
/**
@@ -2570,6 +2570,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
25702570
Nullable<std::string> LeaseId;
25712571
Nullable<bool> AllowTrailingDot;
25722572
Nullable<Models::ShareTokenIntent> FileRequestIntent;
2573+
Nullable<bool> SupportRename;
25732574
};
25742575
static Response<Models::GetFileRangeListResult> GetRangeList(
25752576
Core::Http::_internal::HttpPipeline& pipeline,

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
791791
* The operation will only succeed if the access condition is met.
792792
*/
793793
LeaseAccessConditions AccessConditions;
794+
795+
/**
796+
* This header is allowed only when PreviousSnapshot query parameter is set.
797+
* Determines whether the changed ranges for a file that has been renamed or moved between the
798+
* target snapshot (or the live file) and the previous snapshot should be listed. If the value
799+
* is true, the valid changed ranges for the file will be returned. If the value is false, the
800+
* operation will result in a failure with 409 (Conflict) response.
801+
*/
802+
Azure::Nullable<bool> SupportRename;
794803
};
795804

796805
/**

sdk/storage/azure-storage-files-shares/src/rest_client.cpp

Lines changed: 51 additions & 46 deletions
Large diffs are not rendered by default.

sdk/storage/azure-storage-files-shares/src/share_file_client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
669669
protocolLayerOptions.LeaseId = options.AccessConditions.LeaseId;
670670
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
671671
protocolLayerOptions.FileRequestIntent = m_shareTokenIntent;
672+
protocolLayerOptions.SupportRename = options.SupportRename;
672673
return _detail::FileClient::GetRangeList(
673674
*m_pipeline, m_shareFileUrl, protocolLayerOptions, context);
674675
}

sdk/storage/azure-storage-files-shares/swagger/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package-name: azure-storage-files-shares
99
namespace: Azure::Storage::Files::Shares
1010
output-folder: generated
1111
clear-output-folder: true
12-
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.FileStorage/preview/2024-02-04/file.json
12+
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.FileStorage/preview/2024-05-04/file.json
1313
```
1414
1515
## ModelFour Options
@@ -79,12 +79,12 @@ directive:
7979
"name": "ApiVersion",
8080
"modelAsString": false
8181
},
82-
"enum": ["2024-02-04"]
82+
"enum": ["2024-05-04"]
8383
};
8484
- from: swagger-document
8585
where: $.parameters
8686
transform: >
87-
$.ApiVersionParameter.enum[0] = "2024-02-04";
87+
$.ApiVersionParameter.enum[0] = "2024-05-04";
8888
```
8989
9090
### Rename Operations

sdk/storage/azure-storage-files-shares/test/ut/share_file_client_test.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,43 @@ namespace Azure { namespace Storage { namespace Test {
901901
}
902902
}
903903

904+
TEST_F(FileShareFileClientTest, GetRangeListDiffWithRename_PLAYBACKONLY_)
905+
{
906+
size_t rangeSize = 128;
907+
std::vector<uint8_t> rangeContent = RandomBuffer(rangeSize);
908+
auto memBodyStream = Core::IO::MemoryBodyStream(rangeContent);
909+
std::string sourceFileName = RandomString();
910+
std::string destFileName = RandomString();
911+
912+
auto fileClient = m_shareClient->GetRootDirectoryClient().GetFileClient(sourceFileName);
913+
fileClient.Create(rangeSize);
914+
915+
EXPECT_NO_THROW(fileClient.UploadRange(0, memBodyStream));
916+
917+
auto snapshot = m_shareClient->CreateSnapshot().Value.Snapshot;
918+
EXPECT_NO_THROW(fileClient.ClearRange(64, 64));
919+
920+
fileClient
921+
= m_shareClient->GetRootDirectoryClient().RenameFile(sourceFileName, destFileName).Value;
922+
923+
Files::Shares::GetFileRangeListOptions options;
924+
options.Range = Core::Http::HttpRange();
925+
options.Range.Value().Offset = 64;
926+
options.Range.Value().Length = 64;
927+
Files::Shares::Models::GetFileRangeListResult result;
928+
929+
// SupportRename == true
930+
options.SupportRename = true;
931+
EXPECT_NO_THROW(result = fileClient.GetRangeListDiff(snapshot, options).Value);
932+
EXPECT_EQ(1U, result.Ranges.size());
933+
EXPECT_EQ(64, result.Ranges[0].Offset);
934+
EXPECT_TRUE(result.Ranges[0].Length.HasValue());
935+
936+
// SupportRename == false
937+
options.SupportRename = false;
938+
EXPECT_THROW(fileClient.GetRangeListDiff(snapshot, options), StorageException);
939+
}
940+
904941
TEST_F(FileShareFileClientTest, PreviousRangeWithSnapshot)
905942
{
906943
size_t fileSize = 1024 * 10;

0 commit comments

Comments
 (0)