Skip to content

Commit

Permalink
fix: download single blob (#16)
Browse files Browse the repository at this point in the history
While downloading a subtree or a single file, preserve only directories
after the volume path.
  • Loading branch information
NikitaYurasov authored Sep 3, 2024
1 parent b085b45 commit 72f0fba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dbxio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from dbxio.utils import * # noqa: F403
from dbxio.volume import * # noqa: F403

__version__ = '0.4.2' # single source of truth
__version__ = '0.4.3' # single source of truth
3 changes: 1 addition & 2 deletions dbxio/blobs/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def download_blob_tree(
relative_blob_path = blob.name[len(prefix_path) + 1 :] if prefix_path else blob.name
if not relative_blob_path:
# if the prefix path is full path to one file
assert object_storage_client.blobs_path, 'blobs_path is not set'
relative_blob_path = blob.name[len(object_storage_client.blobs_path) + 1 :]
relative_blob_path = Path(blob.name).name

if is_dir:
if not blob.name.startswith(f'{prefix_path}/'):
Expand Down
1 change: 1 addition & 0 deletions dbxio/core/cloud/azure/object_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def download_blob(self, blob_name: str) -> bytes:
return blob_client.download_blob().readall()

def download_blob_to_file(self, blob_name: str, file_path: Union[str, Path]) -> None:
Path(file_path).parent.mkdir(parents=True, exist_ok=True)
with open(file_path, 'wb') as f:
f.write(self.download_blob(blob_name))

Expand Down

0 comments on commit 72f0fba

Please sign in to comment.