/usr/share/julia/base/pkg/cache.jl is in julia-common 0.4.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # This file is a part of Julia. License is MIT: http://julialang.org/license
module Cache
import ..Git, ..Dir
using ..Types
path(pkg::AbstractString) = abspath(".cache", pkg)
function mkcachedir()
cache = joinpath(realpath("."), ".cache")
if isdir(cache)
return
end
@unix_only if Dir.isversioned(pwd())
rootcache = joinpath(realpath(".."), ".cache")
if !isdir(rootcache)
mkdir(rootcache)
end
symlink(rootcache, cache)
return
end
mkdir(cache)
end
function prefetch(pkg::AbstractString, url::AbstractString, sha1s::Vector)
isdir(".cache") || mkcachedir()
cache = path(pkg)
if !isdir(cache)
info("Cloning cache of $pkg from $url")
try Git.run(`clone -q --mirror $url $cache`)
catch
isdir(cache) && rm(cache, recursive=true)
rethrow()
end
end
Git.set_remote_url(url, dir=cache)
in_cache = Git.iscommit(sha1s, dir=cache)
if !all(in_cache)
info("Updating cache of $pkg...")
Git.success(`remote update`, dir=cache) ||
error("couldn't update $cache using `git remote update`")
in_cache = Git.iscommit(sha1s, dir=cache)
end
sha1s[!in_cache]
end
prefetch(pkg::AbstractString, url::AbstractString, sha1::AbstractString...) = prefetch(pkg, url, AbstractString[sha1...])
end # module
|