Skip to content

Commit

Permalink
read the Registry from the tar ball
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Mar 16, 2021
1 parent c52dd31 commit c2481b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
9 changes: 6 additions & 3 deletions src/Registry/Registry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Registry
import ..Pkg
using ..Pkg: depots1, printpkgstyle, DEFAULT_IO, isdir_nothrow, pathrepr, pkg_server,
GitTools, OFFLINE_MODE, UPDATED_REGISTRY_THIS_SESSION
using ..Pkg.PlatformEngines: download_verify_unpack, download
using ..Pkg.PlatformEngines: download_verify_unpack, download, download_verify
using UUIDs, LibGit2

include("tar_filesystem.jl")
Expand Down Expand Up @@ -175,12 +175,15 @@ function download_registries(io::IO, regs::Vector{RegistrySpec}, depot::String=d
end
# clone to tmpdir first
if registry_read_from_tarball()
regpath = joinpath(depot, "registries", registry.uuid, ".tar.gz")
url, registry_urls = pkg_server_registry_url(reg.uuid, registry_urls)
regpath = joinpath(depot, "registries", string(reg.uuid) * ".tar.gz")
tmp = tempname()
try
download_verify(url, nothing, regpath, ignore_existence = true)
download_verify(url, nothing, tmp)
catch err
Pkg.Types.pkgerror("could not download $url")
end
mv(tmp, regpath; force=true)
else
mktempdir() do tmp
url, registry_urls = pkg_server_registry_url(reg.uuid, registry_urls)
Expand Down
24 changes: 12 additions & 12 deletions src/Registry/registry_instance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,6 @@ function init_package_info!(pkg::PkgEntry)
return pkg.info
end


mutable struct InMemoryRegistry
d::Dict{String, String}
name::String
end
readfile(reg::InMemoryRegistry, path::AbstractString) = reg.d[joinpath(reg.name, path)]

struct RegistryInstance
path::String
name::String
Expand Down Expand Up @@ -270,11 +263,18 @@ function reachable_registries(; depots::Union{String, Vector{String}}=Base.DEPOT
for d in depots
isdir(d) || continue
reg_dir = joinpath(d, "registries")
isdir(reg_dir) || continue
for name in readdir(reg_dir)
file = joinpath(reg_dir, name, "Registry.toml")
isfile(file) || continue
push!(registries, RegistryInstance(joinpath(reg_dir, name); parse_packages))
ispath(reg_dir) || continue
if isfile(reg_dir)
elseif isdir(reg_dir)
for name in readdir(reg_dir)
if isfile(joinpath(reg_dir, name))
push!(registries, RegistryInstance(joinpath(reg_dir, name); parse_packages))
else
file = joinpath(reg_dir, name, "Registry.toml")
isfile(file) || continue
push!(registries, RegistryInstance(joinpath(reg_dir, name); parse_packages))
end
end
end
end
return registries
Expand Down

0 comments on commit c2481b8

Please sign in to comment.