Skip to content

Commit 9045626

Browse files
committed
fixup! Add option to expose connection errors in httpfs.exists
1 parent 3860ee6 commit 9045626

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

fsspec/implementations/http.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,12 @@ async def _exists(self, path, strict=False, **kwargs):
337337
if strict:
338338
self._raise_not_found_for_status(r, path)
339339
return r.status < 400
340-
except (FileNotFoundError, aiohttp.ClientError) as e:
341-
if strict and isinstance(e, FileNotFoundError):
342-
return False
343-
elif strict:
340+
except FileNotFoundError:
341+
return False
342+
except aiohttp.ClientError:
343+
if strict:
344344
raise
345-
else:
346-
return False
345+
return False
347346

348347
async def _isfile(self, path, **kwargs):
349348
return await self._exists(path, **kwargs)

fsspec/implementations/http_sync.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,12 @@ def exists(self, path, strict=False, **kwargs):
472472
if strict:
473473
self._raise_not_found_for_status(r, path)
474474
return r.status_code < 400
475-
except Exception as e:
476-
if strict and isinstance(e, FileNotFoundError):
477-
return False
478-
elif strict:
475+
except FileNotFoundError:
476+
return False
477+
except Exception:
478+
if strict:
479479
raise
480-
else:
481-
return False
480+
return False
482481

483482
def isfile(self, path, **kwargs):
484483
return self.exists(path, **kwargs)

0 commit comments

Comments
 (0)