Skip to content
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
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# cloudpathlib Changelog

## Unreleased

- Fixed `rmtree` fail on Azure with no `hns` and more than 256 blobs to drop (Issue [#509](https://github.com/drivendataorg/cloudpathlib/issues/509), PR [#508](https://github.com/drivendataorg/cloudpathlib/pull/508), thanks @alikefia)

## v0.21.0 (2025-03-03)

- Removed support for deprecated env var that had a typo (`CLOUPATHLIB_FILE_CACHE_MODE`; you should use `CLOUDPATHLIB_FILE_CACHE_MODE`).
Expand Down
8 changes: 5 additions & 3 deletions cloudpathlib/azure/azblobclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from http import HTTPStatus
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, Optional, Tuple, Union
from itertools import islice

try:
from typing import cast
Expand Down Expand Up @@ -437,11 +438,12 @@ def _remove(self, cloud_path: AzureBlobPath, missing_ok: bool = True) -> None:
_hns_rmtree(self.data_lake_client, cloud_path.container, cloud_path.blob)
return

blobs = [
blobs = (
b.blob for b, is_dir in self._list_dir(cloud_path, recursive=True) if not is_dir
]
)
container_client = self.service_client.get_container_client(cloud_path.container)
container_client.delete_blobs(*blobs)
while batch := tuple(islice(blobs, 256)):
container_client.delete_blobs(*batch)
elif file_or_dir == "file":
blob = self.service_client.get_blob_client(
container=cloud_path.container, blob=cloud_path.blob
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mike
mkdocs>=1.2.2
mkdocs-jupyter
mkdocs-material>=7.2.6
mkdocstrings[python-legacy]>=0.19.0
mkdocstrings[python]>=0.19.0
mypy
nbautoexport
pandas
Expand Down
10 changes: 10 additions & 0 deletions tests/test_azure_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,13 @@ def test_adls_gen2_rename(azure_gen2_rig):
p2 = p.rename(azure_gen2_rig.create_cloud_path("dir2"))
assert not p.exists()
assert p2.exists()


def test_batched_rmtree_no_hns(azure_rig):
p = azure_rig.create_cloud_path("new_dir")

p.mkdir()
for i in range(400):
(p / f"{i}.txt").write_text("content")
p.rmtree()
assert not p.exists()