diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 8da26d6e98e..0d1d879f045 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -175,9 +175,11 @@ def list_files(root: str, suffix: str, prefix: bool = False) -> List[str]: def _quota_exceeded(response: "requests.models.Response") -> bool: # type: ignore[name-defined] - return False - # See https://github.com/pytorch/vision/issues/2992 for details - # return "Google Drive - Quota exceeded" in response.text + try: + start = next(response.iter_content(chunk_size=128, decode_unicode=True)) + return isinstance(start, str) and "Google Drive - Quota exceeded" in start + except StopIteration: + return False def download_file_from_google_drive(file_id: str, root: str, filename: Optional[str] = None, md5: Optional[str] = None):