2
2
3
3
# file downloading
4
4
5
- downloadcmd = nothing
6
5
if Sys. iswindows ()
7
- downloadcmd = " powershell"
8
6
function download (url:: AbstractString , filename:: AbstractString )
9
7
ps = " C:\\ Windows\\ System32\\ WindowsPowerShell\\ v1.0\\ powershell.exe"
10
8
tls12 = " [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
@@ -25,28 +23,16 @@ if Sys.iswindows()
25
23
end
26
24
else
27
25
function download (url:: AbstractString , filename:: AbstractString )
28
- global downloadcmd
29
- if downloadcmd === nothing
30
- for checkcmd in (" curl" , " wget" , " fetch" )
31
- try
32
- # Sys.which() will throw() if it can't find `checkcmd`
33
- Sys. which (checkcmd)
34
- downloadcmd = checkcmd
35
- break
36
- catch
37
- end
38
- end
39
- end
40
- if downloadcmd == " wget"
26
+ if Sys. which (" curl" ) != = nothing
27
+ run (` curl -g -L -f -o $filename $url ` )
28
+ elseif Sys. which (" wget" ) != = nothing
41
29
try
42
30
run (` wget -O $filename $url ` )
43
31
catch
44
- rm (filename) # wget always creates a file
32
+ rm (filename, force = true ) # wget always creates a file
45
33
rethrow ()
46
34
end
47
- elseif downloadcmd == " curl"
48
- run (` curl -g -L -f -o $filename $url ` )
49
- elseif downloadcmd == " fetch"
35
+ elseif Sys. which (" fetch" ) != = nothing
50
36
run (` fetch -f $filename $url ` )
51
37
else
52
38
error (" no download agent available; install curl, wget, or fetch" )
0 commit comments