Skip to content

Commit 3afb6e6

Browse files
committed
fixes issue s3 iterdir error when path is only the bucket
1 parent bfc432d commit 3afb6e6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

upath/implementations/s3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def _sub_path(self, name):
2222
so it gets subbed out as well
2323
"""
2424
sp = self.path
25-
return re.sub(f"^{self._url.netloc}/({sp}|{sp[1:]})/", "", name)
25+
subed = re.sub(f"^{self._url.netloc}/({sp}|{sp[1:]})/?", "", name)
26+
return subed

upath/tests/cases.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def test_chmod(self):
2626
"url, expected", [("file1.txt", True), ("fakefile.txt", False)]
2727
)
2828
def test_exists(self, url, expected):
29-
print(self.path)
3029
path = self.path.joinpath(url)
3130
assert path.exists() == expected
3231

@@ -92,9 +91,13 @@ def test_iterdir(self, local_testdir):
9291
up_iter = list(self.path.iterdir())
9392
pl_iter = list(pl_path.iterdir())
9493

94+
for x in up_iter:
95+
assert x.exists()
96+
9597
assert len(up_iter) == len(pl_iter)
9698
pnames = [p.name for p in pl_iter]
9799
assert all(map(lambda x: x.name in pnames, up_iter))
100+
assert next(self.path.parent.iterdir()).exists()
98101

99102
def test_lchmod(self):
100103
with pytest.raises(NotImplementedError):

0 commit comments

Comments
 (0)