986986
987987pkg_server_url_hash (url:: String ) = split (url, ' /' )[end ]
988988
989+ registry_use_pkg_server () =
990+ ! Sys. iswindows () || haskey (ENV , " JULIA_PKG_SERVER" )
991+
989992# entry point for `registry add`
990993function clone_or_cp_registries (ctx:: Context , regs:: Vector{RegistrySpec} , depot:: String = depots1 ())
991994 populate_known_registries_with_urls! (regs)
@@ -998,7 +1001,7 @@ function clone_or_cp_registries(ctx::Context, regs::Vector{RegistrySpec}, depot:
9981001 mktempdir () do tmp
9991002 url, registry_urls = pkg_server_registry_url (reg. uuid, registry_urls)
10001003 # on Windows we prefer git cloning because untarring is so slow
1001- if ! Sys . iswindows () && url != = nothing
1004+ if url != = nothing && registry_use_pkg_server ()
10021005 # download from Pkg server
10031006 try
10041007 download_verify_unpack (url, nothing , tmp, ignore_existence = true )
@@ -1031,7 +1034,7 @@ function clone_or_cp_registries(ctx::Context, regs::Vector{RegistrySpec}, depot:
10311034 # slug = Base.package_slug(UUID(registry["uuid"]))
10321035 regpath = joinpath (depot, " registries" , registry[" name" ]:: String #= , slug=# )
10331036 ispath (dirname (regpath)) || mkpath (dirname (regpath))
1034- if Pkg . isdir_nothrow ( regpath)
1037+ if isfile ( joinpath ( regpath, " Registry.toml " ) )
10351038 existing_registry = read_registry (joinpath (regpath, " Registry.toml" ))
10361039 if registry[" uuid" ] == existing_registry[" uuid" ]
10371040 println (ctx. io,
@@ -1043,7 +1046,7 @@ function clone_or_cp_registries(ctx::Context, regs::Vector{RegistrySpec}, depot:
10431046 " `$(Base. contractuser (joinpath (depot, " registries" , registry[" name" ]* " -2" ))) `." ))
10441047 end
10451048 else
1046- mv (tmp, regpath)
1049+ mv (tmp, regpath, force = true )
10471050 printpkgstyle (ctx, :Added , " registry `$(registry[" name" ]) ` to `$(Base. contractuser (regpath)) `" )
10481051 end
10491052 end
0 commit comments