From 895bc9a3ec54e3124d8b79c642368350723284b7 Mon Sep 17 00:00:00 2001 From: KristofferC Date: Fri, 12 Mar 2021 15:49:31 +0100 Subject: [PATCH] read the Registry from the tar ball --- src/Registry/Registry.jl | 9 ++++++--- src/Registry/registry_instance.jl | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Registry/Registry.jl b/src/Registry/Registry.jl index 0e20dbdd09..83035a8123 100644 --- a/src/Registry/Registry.jl +++ b/src/Registry/Registry.jl @@ -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") @@ -170,12 +170,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) diff --git a/src/Registry/registry_instance.jl b/src/Registry/registry_instance.jl index 9b055d4beb..449de80f30 100644 --- a/src/Registry/registry_instance.jl +++ b/src/Registry/registry_instance.jl @@ -270,11 +270,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