Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage/feature/stg87-trailing dot #4389

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/storage/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/storage",
"Tag": "cpp/storage_92d8f38118"
"Tag": "cpp/storage_fafb185a5f"
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
private:
Azure::Core::Url m_shareUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
Nullable<bool> m_allowTrailingDot;
Nullable<bool> m_allowSourceTrailingDot;

explicit ShareClient(
Azure::Core::Url shareUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
private:
Azure::Core::Url m_shareDirectoryUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
Nullable<bool> m_allowTrailingDot;
Nullable<bool> m_allowSourceTrailingDot;

explicit ShareDirectoryClient(
Azure::Core::Url shareDirectoryUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
private:
Azure::Core::Url m_shareFileUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
Nullable<bool> m_allowTrailingDot;
Nullable<bool> m_allowSourceTrailingDot;

explicit ShareFileClient(
Azure::Core::Url shareFileUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* API version used by this client.
*/
std::string ApiVersion;

/**
* If set to true, trailing dot (.) will be allowed to suffix directory and file names.
* If false, the trailing dot will be trimmed.
* Supported by x-ms-version 2022-11-02 and above.
*/
Nullable<bool> AllowTrailingDot;

/**
* If set to true, trailing dot (.) will be allowed to source file names.
* If false, the trailing dot will be trimmed.
* Supported by x-ms-version 2022-11-02 and above.
*/
Nullable<bool> AllowSourceTrailingDot;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
private:
Azure::Core::Url m_serviceUrl;
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
Nullable<bool> m_allowTrailingDot;
Nullable<bool> m_allowSourceTrailingDot;
};
}}}} // namespace Azure::Storage::Files::Shares
11 changes: 8 additions & 3 deletions sdk/storage/azure-storage-files-shares/src/share_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const std::string& shareUrl,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options)
: m_shareUrl(shareUrl)
: m_shareUrl(shareUrl), m_allowTrailingDot(options.AllowTrailingDot),
m_allowSourceTrailingDot(options.AllowSourceTrailingDot)
{
ShareClientOptions newOptions = options;
newOptions.PerRetryPolicies.emplace_back(
Expand All @@ -63,7 +64,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
}

ShareClient::ShareClient(const std::string& shareUrl, const ShareClientOptions& options)
: m_shareUrl(shareUrl)
: m_shareUrl(shareUrl), m_allowTrailingDot(options.AllowTrailingDot),
m_allowSourceTrailingDot(options.AllowSourceTrailingDot)
{
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perRetryPolicies;
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perOperationPolicies;
Expand All @@ -80,7 +82,10 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {

ShareDirectoryClient ShareClient::GetRootDirectoryClient() const
{
return ShareDirectoryClient(m_shareUrl, m_pipeline);
ShareDirectoryClient directoryClient(m_shareUrl, m_pipeline);
directoryClient.m_allowTrailingDot = m_allowTrailingDot;
directoryClient.m_allowSourceTrailingDot = m_allowSourceTrailingDot;
return directoryClient;
}

ShareClient ShareClient::WithSnapshot(const std::string& snapshot) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
const std::string& shareDirectoryUrl,
std::shared_ptr<StorageSharedKeyCredential> credential,
const ShareClientOptions& options)
: m_shareDirectoryUrl(shareDirectoryUrl)
: m_shareDirectoryUrl(shareDirectoryUrl), m_allowTrailingDot(options.AllowTrailingDot),
m_allowSourceTrailingDot(options.AllowSourceTrailingDot)
{
ShareClientOptions newOptions = options;
newOptions.PerRetryPolicies.emplace_back(
Expand All @@ -67,7 +68,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
ShareDirectoryClient::ShareDirectoryClient(
const std::string& shareDirectoryUrl,
const ShareClientOptions& options)
: m_shareDirectoryUrl(shareDirectoryUrl)
: m_shareDirectoryUrl(shareDirectoryUrl), m_allowTrailingDot(options.AllowTrailingDot),
m_allowSourceTrailingDot(options.AllowSourceTrailingDot)
{
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perRetryPolicies;
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perOperationPolicies;
Expand All @@ -87,14 +89,20 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
auto builder = m_shareDirectoryUrl;
builder.AppendPath(_internal::UrlEncodePath(subdirectoryName));
return ShareDirectoryClient(builder, m_pipeline);
ShareDirectoryClient subdirectoryClient(builder, m_pipeline);
subdirectoryClient.m_allowTrailingDot = m_allowTrailingDot;
subdirectoryClient.m_allowSourceTrailingDot = m_allowSourceTrailingDot;
return subdirectoryClient;
}

ShareFileClient ShareDirectoryClient::GetFileClient(const std::string& fileName) const
{
auto builder = m_shareDirectoryUrl;
builder.AppendPath(_internal::UrlEncodePath(fileName));
return ShareFileClient(builder, m_pipeline);
ShareFileClient fileClient(builder, m_pipeline);
fileClient.m_allowTrailingDot = m_allowTrailingDot;
fileClient.m_allowSourceTrailingDot = m_allowSourceTrailingDot;
return fileClient;
}

ShareDirectoryClient ShareDirectoryClient::WithShareSnapshot(
Expand Down Expand Up @@ -163,6 +171,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
protocolLayerOptions.FilePermission = std::string(FileInheritPermission);
}
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
auto result = _detail::DirectoryClient::Create(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
Models::CreateDirectoryResult ret;
Expand Down Expand Up @@ -244,11 +253,15 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
protocolLayerOptions.FilePermissionKey = options.SmbProperties.PermissionKey;
}
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
protocolLayerOptions.AllowSourceTrailingDot = m_allowSourceTrailingDot;

auto response = _detail::FileClient::Rename(
*m_pipeline, destinationFileUrl, protocolLayerOptions, context);

auto renamedFileClient = ShareFileClient(destinationFileUrl, m_pipeline);
renamedFileClient.m_allowTrailingDot = m_allowTrailingDot;
renamedFileClient.m_allowSourceTrailingDot = m_allowSourceTrailingDot;
return Azure::Response<ShareFileClient>(
std::move(renamedFileClient), std::move(response.RawResponse));
}
Expand Down Expand Up @@ -300,13 +313,17 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
protocolLayerOptions.FilePermissionKey = options.SmbProperties.PermissionKey;
}
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
protocolLayerOptions.AllowSourceTrailingDot = m_allowSourceTrailingDot;

auto response = _detail::DirectoryClient::Rename(
*m_pipeline, destinationDirectoryUrl, protocolLayerOptions, context);

auto renamedFileClient = ShareDirectoryClient(destinationDirectoryUrl, m_pipeline);
auto renamedSubdirectoryClient = ShareDirectoryClient(destinationDirectoryUrl, m_pipeline);
renamedSubdirectoryClient.m_allowTrailingDot = m_allowTrailingDot;
renamedSubdirectoryClient.m_allowSourceTrailingDot = m_allowSourceTrailingDot;
return Azure::Response<ShareDirectoryClient>(
std::move(renamedFileClient), std::move(response.RawResponse));
std::move(renamedSubdirectoryClient), std::move(response.RawResponse));
}

Azure::Response<Models::DeleteDirectoryResult> ShareDirectoryClient::Delete(
Expand All @@ -315,6 +332,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
(void)options;
auto protocolLayerOptions = _detail::DirectoryClient::DeleteDirectoryOptions();
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
auto result = _detail::DirectoryClient::Delete(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
Models::DeleteDirectoryResult ret;
Expand Down Expand Up @@ -351,6 +369,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
(void)options;
auto protocolLayerOptions = _detail::DirectoryClient::GetDirectoryPropertiesOptions();
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
return _detail::DirectoryClient::GetProperties(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
}
Expand Down Expand Up @@ -401,6 +420,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
{
protocolLayerOptions.FilePermission = FilePreserveSmbProperties;
}
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
return _detail::DirectoryClient::SetProperties(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
}
Expand All @@ -414,6 +434,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
auto protocolLayerOptions = _detail::DirectoryClient::SetDirectoryMetadataOptions();
protocolLayerOptions.Metadata
= std::map<std::string, std::string>(metadata.begin(), metadata.end());
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
return _detail::DirectoryClient::SetMetadata(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
}
Expand All @@ -429,6 +450,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.MaxResults = options.PageSizeHint;
protocolLayerOptions.Include = options.Include;
protocolLayerOptions.IncludeExtendedInfo = options.IncludeExtendedInfo;
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
auto response = _detail::DirectoryClient::ListFilesAndDirectoriesSegment(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);

Expand Down Expand Up @@ -499,6 +521,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.Marker = options.ContinuationToken;
protocolLayerOptions.MaxResults = options.PageSizeHint;
protocolLayerOptions.Recursive = options.Recursive;
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
auto response = _detail::DirectoryClient::ListHandles(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);

Expand Down Expand Up @@ -545,6 +568,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
(void)options;
auto protocolLayerOptions = _detail::DirectoryClient::ForceDirectoryCloseHandlesOptions();
protocolLayerOptions.HandleId = handleId;
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
auto result = _detail::DirectoryClient::ForceCloseHandles(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);
Models::ForceCloseDirectoryHandleResult ret;
Expand All @@ -560,6 +584,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.HandleId = FileAllHandles;
protocolLayerOptions.Marker = options.ContinuationToken;
protocolLayerOptions.Recursive = options.Recursive;
protocolLayerOptions.AllowTrailingDot = m_allowTrailingDot;
auto response = _detail::DirectoryClient::ForceCloseHandles(
*m_pipeline, m_shareDirectoryUrl, protocolLayerOptions, context);

Expand Down
Loading