Skip to content

Commit 4150cea

Browse files
authored
fix check for exceeded quota on Google Drive (#3710)
* fix check for exceeded quota on Google Drive * safeguard quota exceed check
1 parent 97b6b15 commit 4150cea

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

torchvision/datasets/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,11 @@ def list_files(root: str, suffix: str, prefix: bool = False) -> List[str]:
175175

176176

177177
def _quota_exceeded(response: "requests.models.Response") -> bool: # type: ignore[name-defined]
178-
return False
179-
# See https://github.com/pytorch/vision/issues/2992 for details
180-
# return "Google Drive - Quota exceeded" in response.text
178+
try:
179+
start = next(response.iter_content(chunk_size=128, decode_unicode=True))
180+
return isinstance(start, str) and "Google Drive - Quota exceeded" in start
181+
except StopIteration:
182+
return False
181183

182184

183185
def download_file_from_google_drive(file_id: str, root: str, filename: Optional[str] = None, md5: Optional[str] = None):

0 commit comments

Comments
 (0)