Skip to content

Commit 7f507e6

Browse files
If cache.julialang.org is down, try to download Busybox from the upstream URL (#47015)
Co-authored-by: LilithHafner <lilithhafner@gmail.com> Co-authored-by: LilithHafner <lilithhafner@gmail.com>
1 parent b722507 commit 7f507e6

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

test/spawn.jl

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
###################################
66

77
using Random, Sockets
8-
using Downloads: download
8+
using Downloads: Downloads, download
99

1010
valgrind_off = ccall(:jl_running_on_valgrind, Cint, ()) == 0
1111

@@ -20,8 +20,33 @@ shcmd = `sh`
2020
sleepcmd = `sleep`
2121
lscmd = `ls`
2222
havebb = false
23+
24+
function _tryonce_download_from_cache(desired_url::AbstractString)
25+
cache_url = "https://cache.julialang.org/foo/$(desired_url)"
26+
cache_output_filename = joinpath(mktempdir(), "myfile")
27+
cache_response = Downloads.request(
28+
cache_url;
29+
output = cache_output,
30+
throw = false,
31+
timeout = 60,
32+
)
33+
if cache_response isa Downloads.Response
34+
if Downloads.status_ok(cache_response.proto, cache_response.status)
35+
return cache_output_filename
36+
end
37+
end
38+
return Downloads.download(desired_url; timeout = 60)
39+
end
40+
41+
function download_from_cache(desired_url::AbstractString)
42+
f = () -> _tryonce_download_from_cache(desired_url)
43+
delays = Float64[30, 30, 60, 60, 60]
44+
g = retry(f; delays)
45+
return g()
46+
end
47+
2348
if Sys.iswindows()
24-
busybox = download("https://cache.julialang.org/https://frippery.org/files/busybox/busybox.exe", joinpath(tempdir(), "busybox.exe"))
49+
busybox = download_from_cache("https://frippery.org/files/busybox/busybox.exe")
2550
havebb = try # use busybox-w32 on windows, if available
2651
success(`$busybox`)
2752
true

0 commit comments

Comments
 (0)