Skip to content

Commit cfbf325

Browse files
authored
Merge pull request #741 from martindurant/http_isdir
isdir to give false when http url does not exist
2 parents 399cf82 + 34c305c commit cfbf325

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fsspec/implementations/http.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,10 @@ async def _glob(self, path, **kwargs):
472472

473473
async def _isdir(self, path):
474474
# override, since all URLs are (also) files
475-
return bool(await self._ls(path))
475+
try:
476+
return bool(await self._ls(path))
477+
except (FileNotFoundError, ValueError):
478+
return False
476479

477480

478481
class HTTPFile(AbstractBufferedFile):

fsspec/implementations/tests/test_http.py

+1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def test_isdir(server):
276276
h = fsspec.filesystem("http")
277277
assert h.isdir(server + "/index/")
278278
assert not h.isdir(server + "/index/realfile")
279+
assert not h.isdir(server + "doesnotevenexist")
279280

280281

281282
def test_policy_arg(server):

0 commit comments

Comments
 (0)