-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[DataLake][Rename]Rename with Sas #12057
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
73f3680
[DataLake][Rename]Rename with Sas
xiafu-msft bf5d864
small fix
xiafu-msft 5c099aa
recordings
xiafu-msft 49f9ad4
Merge branch 'master' into rename-with-sas
xiafu-msft 7dfc073
fix pylint
xiafu-msft 3e6c88c
fix pylint
xiafu-msft 0b117ea
fix pylint
xiafu-msft 3b5af8b
Update sdk/storage/azure-storage-file-datalake/azure/storage/filedata…
xiafu-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,10 @@ | |
# license information. | ||
# -------------------------------------------------------------------------- | ||
# pylint: disable=invalid-overridden-method | ||
|
||
try: | ||
from urllib.parse import quote, unquote | ||
except ImportError: | ||
from urllib2 import quote, unquote # type: ignore | ||
from ._data_lake_file_client_async import DataLakeFileClient | ||
from .._data_lake_directory_client import DataLakeDirectoryClient as DataLakeDirectoryClientBase | ||
from .._models import DirectoryProperties | ||
|
@@ -270,16 +273,28 @@ async def rename_directory(self, new_name, # type: str | |
""" | ||
new_name = new_name.strip('/') | ||
new_file_system = new_name.split('/')[0] | ||
path = new_name[len(new_file_system):] | ||
new_path_and_token = new_name[len(new_file_system):].split('?') | ||
new_path = new_path_and_token[0] | ||
try: | ||
new_dir_sas = new_path_and_token[1] or self._query_str.strip('?') | ||
except IndexError: | ||
if not self._raw_credential and new_file_system != self.file_system_name: | ||
raise ValueError("please provide the sas token for the new directory") | ||
if not self._raw_credential and new_file_system == self.file_system_name: | ||
new_dir_sas = self._query_str.strip('?') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment above applies to async as well |
||
|
||
new_directory_client = DataLakeDirectoryClient( | ||
self.url, new_file_system, directory_name=path, credential=self._raw_credential, | ||
"{}://{}".format(self.scheme, self.primary_hostname), new_file_system, directory_name=new_path, | ||
credential=self._raw_credential or new_dir_sas, | ||
_hosts=self._hosts, _configuration=self._config, _pipeline=self._pipeline, | ||
_location_mode=self._location_mode, require_encryption=self.require_encryption, | ||
key_encryption_key=self.key_encryption_key, | ||
key_resolver_function=self.key_resolver_function) | ||
await new_directory_client._rename_path('/' + self.file_system_name + '/' + self.path_name, # pylint: disable=protected-access | ||
**kwargs) | ||
await new_directory_client._rename_path( # pylint: disable=protected-access | ||
'/{}/{}{}'.format(quote(unquote(self.file_system_name)), | ||
quote(unquote(self.path_name)), | ||
self._query_str), | ||
**kwargs) | ||
return new_directory_client | ||
|
||
async def create_sub_directory(self, sub_directory, # type: Union[DirectoryProperties, str] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there is unnecessary code duplication in
_data_lake_file_client.py
and_data_lake_directory_client.py
maybe we should create a method inpath_client
that we can use to getnew_file_sas
,new_path_and_token
andnew_path
? what do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me take a look again...