Skip to content

Commit 604ccb7

Browse files
DilumAluthgeLilithHafner
andcommitted
If cache.julialang.org is down, try to download Busybox from the upstream URL
Co-authored-by: LilithHafner <[email protected]>
1 parent b34f882 commit 604ccb7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/spawn.jl

Lines changed: 19 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,25 @@ 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/$(desired_url)"
26+
cache_head_response = Downloads.request(cache_url; method = "HEAD")
27+
if cache_head_response.status < 400
28+
return Downloads.download(cache_url)
29+
end
30+
return Downloads.download(desired_url)
31+
end
32+
33+
function download_from_cache(desired_url::AbstractString)
34+
f = () -> _tryonce_download_from_cache(desired_url)
35+
delays = Float64[30, 30, 60, 60, 60]
36+
g = retry(f; delays)
37+
return g()
38+
end
39+
2340
if Sys.iswindows()
24-
busybox = download("https://cache.julialang.org/https://frippery.org/files/busybox/busybox.exe", joinpath(tempdir(), "busybox.exe"))
41+
busybox = download_from_cache("https://frippery.org/files/busybox/busybox.exe")
2542
havebb = try # use busybox-w32 on windows, if available
2643
success(`$busybox`)
2744
true

0 commit comments

Comments
 (0)