Skip to content

Commit

Permalink
If cache.julialang.org is down, try to download Busybox from the up…
Browse files Browse the repository at this point in the history
…stream URL

Co-authored-by: LilithHafner <[email protected]>
  • Loading branch information
DilumAluthge and LilithHafner committed Oct 3, 2022
1 parent 9105064 commit 6781838
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/spawn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
###################################

using Random, Sockets
using Downloads: download
using Downloads: Downloads, download

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

Expand All @@ -20,8 +20,25 @@ shcmd = `sh`
sleepcmd = `sleep`
lscmd = `ls`
havebb = false

function _tryonce_download_from_cache(desired_url::AbstractString)
cache_url = "https://cache.julialang.org/$(desired_url)"
cache_head_response = Downloads.request(cache_url; method = "HEAD")
if cache_head_response.status < 400
return Downloads.download(cache_url)
end
return Downloads.download(desired_url)
end

function download_from_cache(desired_url::AbstractString)
f = () -> _tryonce_download_from_cache(desired_url)
delays = Float64[30, 30, 60, 60, 60]
g = retry(f; delays)
return g()
end

if Sys.iswindows()
busybox = download("https://cache.julialang.org/https://frippery.org/files/busybox/busybox.exe", joinpath(tempdir(), "busybox.exe"))
busybox = download_from_cache("https://frippery.org/files/busybox/busybox.exe")
havebb = try # use busybox-w32 on windows, if available
success(`$busybox`)
true
Expand Down

0 comments on commit 6781838

Please sign in to comment.