From 6163dd5ca06efe05a7d4645f6b4127847ce133ac Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 9 May 2022 13:31:55 -0700 Subject: [PATCH] URLFile: raise exception if remote URL doesn't exist when using cache (#24432) * URLFile returns empty bytes if using cache and remote file doesn't exist * better exception * assert on cached files --- tools/lib/url_file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/url_file.py b/tools/lib/url_file.py index 8ad2f96b3a..1e94a588f1 100644 --- a/tools/lib/url_file.py +++ b/tools/lib/url_file.py @@ -87,6 +87,7 @@ class URLFile: file_begin = self._pos file_end = self._pos + ll if ll is not None else self.get_length() + assert file_end != -1, f"Remote file is empty or doesn't exist: {self._url}" # We have to align with chunks we store. Position is the begginiing of the latest chunk that starts before or at our file position = (file_begin // CHUNK_SIZE) * CHUNK_SIZE response = b""