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

Restore #3344 and fix #5612 #5617

Merged
merged 2 commits into from
Jan 30, 2014
Merged
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: 28 additions & 1 deletion base/pkg/cache.jl
Original file line number Diff line number Diff line change
@@ -3,10 +3,37 @@ module Cache
import ..Git
using ..Types

import ..Dir: pkgroot

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

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

@windows_only mkdir(cache)
@unix_only begin
rootcache = joinpath(realpath(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")
10 changes: 6 additions & 4 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
@@ -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...)