Skip to content

Commit

Permalink
Bug: Fix rm api add wrong objects bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Sep 25, 2024
1 parent b8e1f29 commit 00ed67e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,6 @@ def _call_list_objects_type2(
return self.tos_client.list_objects_type2(
bucket,
prefix=key.rstrip("/") + "/",
delimiter="/",
max_keys=LS_OPERATION_DEFAULT_MAX_ITEMS,
continuation_token=continuation_token,
)
Expand All @@ -1239,7 +1238,7 @@ def _call_list_objects_type2(
)
is_truncated = resp.is_truncated
continuation_token = resp.next_continuation_token
all_results.extend(resp.contents)
all_results = resp.contents

deleting_objects = [
DeletingObject(o.key if hasattr(o, "key") else o.prefix)
Expand Down
7 changes: 7 additions & 0 deletions tosfs/tests/test_tosfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ def test_find(tosfs: TosFileSystem, bucket: str, temporary_workspace: str) -> No
)
assert result[f"{bucket}/{temporary_workspace}"]["type"] == "directory"

result = tosfs.find(
f"{bucket}/{temporary_workspace}/", withdirs=True, maxdepth=1, detail=True
)
assert len(result) == 1

dir_name = random_str()
sub_dir_name = random_str()
file_name = random_str()
Expand Down Expand Up @@ -683,7 +688,9 @@ def test_rm(tosfs: TosFileSystem, bucket: str, temporary_workspace: str) -> None
f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}/{sub_file_name}"
)
tosfs.rm(f"{bucket}/{temporary_workspace}/{dir_name}", recursive=True)
assert not tosfs.exists(f"{bucket}/{temporary_workspace}/{dir_name}/{sub_file_name}")
assert not tosfs.exists(f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}")
assert not tosfs.exists(f"{bucket}/{temporary_workspace}/{dir_name}/{sub_dir_name}/{sub_file_name}")
assert not tosfs.exists(f"{bucket}/{temporary_workspace}/{dir_name}")

# Test Deletion of Non-Existent Path
Expand Down

0 comments on commit 00ed67e

Please sign in to comment.