Skip to content

Commit

Permalink
Merge pull request #5617 from JuliaLang/fix_5615
Browse files Browse the repository at this point in the history
Restore #3344 and fix #5612, #5615
  • Loading branch information
jiahao committed Jan 30, 2014
2 parents d5399d0 + 3dce623 commit c49b0d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
29 changes: 28 additions & 1 deletion base/pkg/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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

1 comment on commit c49b0d3

@kmsquire
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this, @jiahao and @ihnorton.

Please sign in to comment.