@@ -53,26 +53,10 @@ const DEFAULT_REGISTRIES =
5353 uuid = UUID (" 23338594-aafe-5451-b93e-139f81909106" ),
5454 url = " https://github.com/JuliaRegistries/General.git" )]
5555
56- # Use the pattern
57- #
58- # registry_urls = nothing
59- # for ...
60- # url, registry_urls = pkg_server_registry_url(uuid, registry_urls)
61- # end
62- #
63- # to query the pkg server at most once for registries.
64- pkg_server_registry_url (uuid:: UUID , :: Nothing ) =
65- pkg_server_registry_url (uuid, pkg_server_registry_urls ())
66-
67- pkg_server_registry_url (uuid:: UUID , registry_urls:: Dict{UUID, String} ) =
68- get (registry_urls, uuid, nothing ), registry_urls
69-
70- pkg_server_registry_url (:: Nothing , registry_urls) = nothing , registry_urls
71-
72- function pkg_server_registry_urls ()
73- registry_urls = Dict {UUID, String} ()
56+ function pkg_server_registry_info ()
57+ registry_info = Dict {UUID, Base.SHA1} ()
7458 server = pkg_server ()
75- server === nothing && return registry_urls
59+ server === nothing && return nothing
7660 tmp_path = tempname ()
7761 download_ok = false
7862 try
@@ -85,13 +69,24 @@ function pkg_server_registry_urls()
8569 open (tmp_path) do io
8670 for line in eachline (io)
8771 if (m = match (r" ^/registry/([^/]+)/([^/]+)$" , line)) != = nothing
88- uuid = UUID (m. captures[1 ])
89- hash = String (m. captures[2 ])
90- registry_urls [uuid] = " $server /registry/ $uuid / $ hash"
72+ uuid = UUID (m. captures[1 ]:: SubString{String} )
73+ hash = Base . SHA1 (m. captures[2 ]:: SubString{String} )
74+ registry_info [uuid] = hash
9175 end
9276 end
9377 end
9478 Base. rm (tmp_path, force= true )
79+ return server, registry_info
80+ end
81+
82+ function pkg_server_registry_urls ()
83+ server_registry_info = pkg_server_registry_info ()
84+ registry_urls = Dict {UUID, String} ()
85+ server_registry_info === nothing && return registry_urls
86+ server, registry_info = server_registry_info
87+ for (uuid, hash) in registry_info
88+ registry_urls[uuid] = " $server /registry/$uuid /$hash "
89+ end
9590 return registry_urls
9691end
9792
@@ -166,12 +161,12 @@ function download_registries(io::IO, regs::Vector{RegistrySpec}, depot::String=d
166161 populate_known_registries_with_urls! (regs)
167162 regdir = joinpath (depot, " registries" )
168163 isdir (regdir) || mkpath (regdir)
169- registry_urls = nothing
164+ registry_urls = pkg_server_registry_urls ()
170165 for reg in regs
171166 if reg. path != = nothing && reg. url != = nothing
172167 Pkg. Types. pkgerror (" ambiguous registry specification; both url and path is set." )
173168 end
174- url, registry_urls = pkg_server_registry_url ( reg. uuid, registry_urls )
169+ url = get (registry_urls, reg. uuid, nothing )
175170 if url != = nothing && registry_read_from_tarball ()
176171 tmp = tempname ()
177172 try
@@ -347,14 +342,14 @@ update(regs::Vector{String}; kwargs...) = update([RegistrySpec(name = name) for
347342function update (regs:: Vector{RegistrySpec} = RegistrySpec[]; io:: IO = stderr_f (), force:: Bool = true )
348343 isempty (regs) && (regs = reachable_registries (; depots= depots1 ()))
349344 errors = Tuple{String, String}[]
350- registry_urls = nothing
345+ registry_urls = pkg_server_registry_urls ()
351346 for reg in unique (r -> r. uuid, find_installed_registries (io, regs); seen= Set {UUID} ())
352347 let reg= reg
353348 regpath = pathrepr (reg. path)
354349 if reg. tree_info != = nothing
355350 printpkgstyle (io, :Updating , " registry at " * regpath)
356351 old_hash = reg. tree_info
357- url, registry_urls = pkg_server_registry_url ( reg. uuid, registry_urls )
352+ url = get (registry_urls, reg. uuid, nothing )
358353 if url != = nothing
359354 check_registry_state (reg)
360355 end
0 commit comments