Skip to content

Commit 10e6fbc

Browse files
committed
http: simplify the non existent file logic for info()
1 parent dbf3c69 commit 10e6fbc

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

fsspec/implementations/http.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ async def _info(self, url, **kwargs):
367367
corresponding file will not work).
368368
"""
369369
info = {}
370-
failed = exc = None
371370
session = await self.set_session()
372371

373372
for policy in ["head", "get"]:
@@ -383,16 +382,13 @@ async def _info(self, url, **kwargs):
383382
)
384383
if info.get("size") is not None:
385384
break
386-
except Exception as e:
387-
failed = policy
388-
exc = e
389-
logger.debug((str(e)))
390-
391-
if failed == "get":
392-
# If get failed, then raise a FileNotFoundError
393-
raise FileNotFoundError(url) from exc
394-
else:
395-
return {"name": url, "size": None, **info, "type": "file"}
385+
except Exception as exc:
386+
if policy == "get":
387+
# If get failed, then raise a FileNotFoundError
388+
raise FileNotFoundError(url) from exc
389+
logger.debug(str(exc))
390+
391+
return {"name": url, "size": None, **info, "type": "file"}
396392

397393
async def _glob(self, path, **kwargs):
398394
"""

0 commit comments

Comments
 (0)