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

Make versioned .julia/v0.x dir by default. #3344

Merged
Merged
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
29 changes: 27 additions & 2 deletions base/pkg/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@ module Cache
import ..Git
using ..Types

path(pkg::String) = abspath(".cache", pkg)
import ..Dir: pkgroot, path

function mkcachedir()
cache = realpath(abspath(".cache"))
if isdir(cache)
return
end

@windows_only mkdir(cache)
@unix_only begin
rootcache = realpath(joinpath(pkgroot(), ".cache"))
if rootcache == cache
mkdir(cache)
elseif isdir(rootcache)
try
ln(rootcache, cache)
catch
mkdir(cache)
end
else
mkdir(rootcache)
mkcachedir()
end
end
end


function prefetch{S<:String}(pkg::String, url::String, sha1s::Vector{S})
isdir(".cache") || mkdir(".cache")
isdir(".cache") || mkcachedir()
cache = path(pkg)
if !isdir(cache)
info("Cloning cache of $pkg from $url")
Expand Down
10 changes: 6 additions & 4 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import ..Git

const DIR_NAME = ".julia"

pkgroot() = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME)))

function path()
b = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME)))
b = pkgroot()
x, y = VERSION.major, VERSION.minor
d = joinpath(b,"v$x.$y")
isdir(d) && return d
d = joinpath(b,"v$x")
isdir(d) && return d
if isdir(d) || !isdir(b) || !isdir(joinpath(b, "METADATA"))
return d
end
return b
end
path(pkg::String...) = normpath(path(),pkg...)
Expand Down