Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop the deprecated download #45853

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions base/download.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,3 @@ Downloads() = require(PkgId(
UUID((0xf43a241f_c20a_4ad4, 0x852c_f6b1247861c6)),
"Downloads",
))

"""
download(url::AbstractString, [path::AbstractString = tempname()]) -> path

Download a file from the given url, saving it to the location `path`, or if not
specified, a temporary path. Returns the path of the downloaded file.

!!! note
Since Julia 1.6, this function is deprecated and is just a thin wrapper
around `Downloads.download`. In new code, you should use that function
directly instead of calling this.
"""
download(url::AbstractString, path::AbstractString) = do_download(url, path)
download(url::AbstractString) = do_download(url, nothing)

function do_download(url::AbstractString, path::Union{AbstractString, Nothing})
depwarn("Base.download is deprecated; use Downloads.download instead", :download)
invokelatest(Downloads().download, url, path)
end
5 changes: 0 additions & 5 deletions test/download.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

cmd = `$(Base.julia_cmd()) --depwarn=no --startup-file=no download_exec.jl`
if !success(pipeline(cmd; stdout=stdout, stderr=stderr))
error("download test failed, cmd : $cmd")
end
31 changes: 0 additions & 31 deletions test/download_exec.jl
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

module TestDownload

using Test

mktempdir() do temp_dir
# Download a file
file = joinpath(temp_dir, "ip")
@test download("https://httpbin.julialang.org/ip", file) == file
@test isfile(file)
@test !isempty(read(file))
ip = read(file, String)

# Download an empty file
empty_file = joinpath(temp_dir, "empty")
@test download("https://httpbin.julialang.org/status/200", empty_file) == empty_file
@test isfile(empty_file)
@test isempty(read(empty_file))

# Make sure that failed downloads do not leave files around
missing_file = joinpath(temp_dir, "missing")
@test_throws Exception download("https://httpbin.julialang.org/status/404", missing_file)
@test !isfile(missing_file)

# Use a TEST-NET (192.0.2.0/24) address which shouldn't be bound
invalid_host_file = joinpath(temp_dir, "invalid_host")
@test_throws Exception download("http://192.0.2.1", invalid_host_file)
@test !isfile(invalid_host_file)
end

end # module