Skip to content

Commit

Permalink
fix az storage copy with wildcard '*' in source share file path
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinhzy committed Dec 23, 2024
1 parent 3c540df commit a8a27ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _get_client(client, kwargs):
directory_path = directory_path.replace('./', '', 1)
dir_client = client.get_directory_client(directory_path=directory_path)
file_name = kwargs.pop("file_name", None)
if file_name:
if file_name and file_name != '*':
total_path = directory_path + '/' + file_name if directory_path else file_name
dir_client = client.get_directory_client(directory_path=total_path)
exists = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,19 @@ def test_storage_azcopy_file_account(self, resource_group, storage_account_info,
self.assertEqual(3, sum(len(d) for r, d, f in os.walk(local_folder)))
self.assertEqual(21, sum(len(f) for r, d, f in os.walk(local_folder)))

# Copy with wildcard *
self.cmd('storage directory create -s {} -n {} --account-name {}'.format(share, 'parent', storage_account))
self.cmd('storage directory create -s {} -n {} --account-name {}'
.format(share, 'parent/source', storage_account))
self.cmd('storage copy --source-local-path "{}" --destination-account-name {} --destination-share {} '
'--destination-file-path {} --recursive'
.format(os.path.join(test_dir, 'butter/file_*'), storage_account, share, 'parent/source'))
self.cmd('storage copy --source-account-name {} --source-share {} --source-file-path {} --account-name {} '
'--destination-share {} --destination-file-path {} --recursive -- --as-subdir=false'
.format(storage_account, share, 'parent/source/*', storage_account, share, 'parent/target'))
self.cmd('storage file list -s {} --path {} --account-name {}'.format(
share, 'parent/target', storage_account), checks=JMESPathCheck('length(@)', 10))

@ResourceGroupPreparer()
@StorageAccountPreparer(parameter_name='first_account', allow_shared_key_access=False)
@StorageAccountPreparer(parameter_name='second_account', sku='Premium_LRS', kind='BlockBlobStorage',
Expand Down

0 comments on commit a8a27ec

Please sign in to comment.