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
2 changes: 2 additions & 0 deletions s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,15 @@ def split_path(self, path) -> tuple[str, str, str | None]:
>>> split_path("s3://mybucket/path/to/versioned_file?versionId=some_version_id")
['mybucket', 'path/to/versioned_file', 'some_version_id']
"""
trail = path[len(path.rstrip("/")) :]
path = self._strip_protocol(path)
path = path.lstrip("/")
if "/" not in path:
return path, "", None
else:
bucket, keypart = self._find_bucket_key(path)
key, _, version_id = keypart.partition("?versionId=")
key += trail # restore trailing slashes removed by AbstractFileSystem._strip_protocol
return (
bucket,
key,
Expand Down
11 changes: 11 additions & 0 deletions s3fs/tests/test_s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3085,3 +3085,14 @@ async def run_program(run):
aiobotocore.httpsession.AIOHTTPSession
asyncio.run(run_program(True))
asyncio.run(run_program(False))


def test_rm_recursive_prfix(s3):
prefix = "logs/" # must end with "/"

# Create empty "directory" in S3
client = get_boto3_client()
client.put_object(Bucket=test_bucket_name, Key=prefix, Body=b"")
logs_path = f"s3://{test_bucket_name}/{prefix}"
s3.rm(logs_path, recursive=True)
assert not s3.isdir(logs_path)
Loading