Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from JuliaPackaging/sf/safe_isfile
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat authored Apr 3, 2018
2 parents 8726d9c + 83a73f5 commit 08a314a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ export Prefix, bindir, libdir, includedir, logdir, activate, deactivate,
extract_platform_key, install, uninstall, manifest_from_url,
manifest_for_file, list_tarball_files, verify, temp_prefix, package


# Temporary hack around https://github.com/JuliaLang/julia/issues/26685
function safe_isfile(path)
try
return isfile(path)
catch e
if typeof(e) <: Base.UVError && e.code == Base.UV_EINVAL
return false
end
rethrow(e)
end
end

"""
temp_prefix(func::Function)
Expand Down Expand Up @@ -270,7 +283,7 @@ function install(tarball_url::AbstractString,
try mkpath(dirname(tarball_path)) end

# Check to see if we're "installing" from a file
if isfile(tarball_url)
if safe_isfile(tarball_url)
# If we are, just verify it's already downloaded properly
tarball_path = tarball_url

Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ const libfoo_downloads = Dict(
# Test manually downloading and using libfoo
@testset "Downloading" begin
temp_prefix() do prefix
foo_path = joinpath(prefix,"foo")
touch(foo_path)
# Quick one-off tests for `safe_isfile()`:
@test BinaryProvider.safe_isfile(foo_path)
@test !BinaryProvider.safe_isfile("http://google.com")

if !haskey(libfoo_downloads, platform)
Compat.@warn("Platform $platform does not have a libfoo download, skipping download tests")
else
Expand Down

0 comments on commit 08a314a

Please sign in to comment.