liormizr / s3path

s3path is a pathlib extension for AWS S3 Service
Apache License 2.0
209 stars 41 forks source link

iterdir returns an S3Path for empty directories #80

Closed a-wang24 closed 3 years ago

a-wang24 commented 3 years ago

When calling iterdir() on an empty S3Path object, a single path is still returned. This differs from the pathlib.Path behavior where iterdir() on an empty Path is an empty generator.

Example:

from s3path import S3Path
from pathlib import Path

s3p = S3Path("/path/to/empty/s3dir/")
p = Path("/path/to/empty/dir")

for child in s3p.iterdir():
    print(child)  # prints /path/to/empty/s3dir/

for child in p.iterdir():
    print(child)  # never prints
liormizr commented 3 years ago

Very interesting issue Thank you for that...

PR: #81

I'll add this fix to the next version and update here when it will be deployed

a-wang24 commented 3 years ago

Awesome, thank you for the quick turnaround!

liormizr commented 3 years ago

Deployed Version: 0.3.02