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

Remove full-depth traversal - only list items in the requested 'directory' #871

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from 1 commit
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
24 changes: 3 additions & 21 deletions barman/cloud_providers/azure_blob_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,26 +290,6 @@ def _create_bucket(self):
# the storage account level in Azure)
self.container_client.create_container()

def _walk_blob_tree(self, obj, ignore=None):
"""
Walk a blob tree in a directory manner and return a list of directories
and files.

:param ItemPaged[BlobProperties] obj: Iterable response of BlobProperties
obtained from ContainerClient.walk_blobs
:param str|None ignore: An entry to be excluded from the returned list,
typically the top level prefix
:return: List of objects and directories in the tree
:rtype: List[str]
"""
if obj.name != ignore:
yield obj.name
if isinstance(obj, BlobPrefix):
# We are a prefix and not a leaf so iterate children
for child in obj:
for v in self._walk_blob_tree(child):
yield v

def list_bucket(self, prefix="", delimiter=DEFAULT_DELIMITER):
"""
List bucket content in a directory manner
Expand All @@ -322,7 +302,9 @@ def list_bucket(self, prefix="", delimiter=DEFAULT_DELIMITER):
res = self.container_client.walk_blobs(
name_starts_with=prefix, delimiter=delimiter
)
return self._walk_blob_tree(res, ignore=prefix)

for item in res:
yield item.name

def download_file(self, key, dest_path, decompress=None):
"""
Expand Down
Loading