File tree Expand file tree Collapse file tree 1 file changed +30
-10
lines changed
Expand file tree Collapse file tree 1 file changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -345,16 +345,36 @@ def download(url: str, target_dir: Path) -> Path:
345345
346346 out_path = target_path / basename (url )
347347 if not Path (out_path ).is_file ():
348- run ([
349- "curl" ,
350- "-Lf" ,
351- "--retry" ,
352- "5" ,
353- "--retry-all-errors" ,
354- "-o" ,
355- out_path ,
356- url ,
357- ])
348+ curl_attempts = [
349+ [],
350+ # Retry over HTTP/1.1 if the initial transfer fails with a curl
351+ # transport error (commonly seen with some runner/proxy setups).
352+ ["--http1.1" ],
353+ ]
354+ for i , extra_args in enumerate (curl_attempts , 1 ):
355+ try :
356+ run ([
357+ "curl" ,
358+ "-Lf" ,
359+ "--retry" ,
360+ "5" ,
361+ "--retry-all-errors" ,
362+ * extra_args ,
363+ "-o" ,
364+ out_path ,
365+ url ,
366+ ])
367+ except CalledProcessError as exc :
368+ if i < len (curl_attempts ) and exc .returncode in {16 , 56 , 92 }:
369+ out_path .unlink (missing_ok = True )
370+ print (
371+ f"curl exited { exc .returncode } ; "
372+ "retrying download with --http1.1"
373+ )
374+ continue
375+ raise
376+ else :
377+ break
358378 else :
359379 print (f"Using cached version of { basename (url )} " )
360380 return out_path
You can’t perform that action at this time.
0 commit comments