diff --git a/src/Registry/Registry.jl b/src/Registry/Registry.jl index 0d2370cd8e..805de76d5c 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") @@ -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) diff --git a/src/Registry/registry_instance.jl b/src/Registry/registry_instance.jl index 9b055d4beb..ce292644f9 100644 --- a/src/Registry/registry_instance.jl +++ b/src/Registry/registry_instance.jl @@ -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 @@ -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