filereader should use connection pool for file_exists (#31158)

* filereader should use connection pool for file_exists

* remove debug var
old-commit-hash: 6901aada14df6aa68b5e3970da0487b8d2b4df8c
This commit is contained in:
Greg Hogan
2024-01-25 13:26:12 -08:00
committed by GitHub
parent 231932d962
commit 01eccef5de

View File

@@ -1,5 +1,4 @@
import os
import requests
from openpilot.tools.lib.url_file import URLFile
@@ -13,7 +12,7 @@ def resolve_name(fn):
def file_exists(fn):
fn = resolve_name(fn)
if fn.startswith(("http://", "https://")):
return requests.head(fn, allow_redirects=True).status_code == 200
return URLFile(fn).get_length_online() != -1
return os.path.exists(fn)
def FileReader(fn, debug=False):