Skip to content

Commit

Permalink
fix networking issues
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Feb 9, 2025
1 parent e469a38 commit b0e38b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
7 changes: 4 additions & 3 deletions packages/commands/install/install.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Commands::Install
*,
reporter : Reporter? = nil,
store : ::Store? = nil,
raise_on_failure : Bool = false
raise_on_failure : Bool = false,
)
state = uninitialized State
reporter ||= config.silent ? Reporter::Null.new : Reporter::Interactive.new
Expand Down Expand Up @@ -164,7 +164,7 @@ module Commands::Install
inferred_context : Core::Config::InferredContext,
install_config : Install::Config,
lockfile : Data::Lockfile,
workspaces : Workspaces?
workspaces : Workspaces?,
)
unless config.silent
workers_info = begin
Expand Down Expand Up @@ -206,7 +206,7 @@ module Commands::Install
install_config : Install::Config,
lockfile : Data::Lockfile,
context : Core::Config::InferredContext,
reporter : Reporter
reporter : Reporter,
) : Core::Config
if !config.global && lockfile.strategy && lockfile.strategy != install_config.strategy
Log.debug { "Install strategy changed from #{lockfile.strategy} to #{install_config.strategy}" if lockfile.strategy }
Expand Down Expand Up @@ -290,6 +290,7 @@ module Commands::Install
end

private def self.resolve_dependencies(state : State)
state.pipeline.set_concurrency(state.config.network_concurrency * 3)
state.reporter.report_resolver_updates do
# Resolve overrides
Log.debug { "• Resolving overrides" }
Expand Down
29 changes: 15 additions & 14 deletions packages/commands/install/protocol/registry/resolver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Commands::Install::Protocol::Registry::Resolver < Commands::Install::Prot
specifier = "latest",
parent = nil,
dependency_type = nil,
skip_cache = false
skip_cache = false,
)
super

Expand Down Expand Up @@ -73,25 +73,26 @@ struct Commands::Install::Protocol::Registry::Resolver < Commands::Install::Prot
shasum = dist.shasum
version = metadata.version
unsupported_algorithm = false
algorithm, hash, algorithm_instance = nil, nil, nil
algorithm, hash = nil, nil

if integrity
algorithm, hash = integrity.split("-")
else
unsupported_algorithm = true
end

algorithm_instance = case algorithm
when "sha1"
Digest::SHA1.new
when "sha256"
Digest::SHA256.new
when "sha512"
Digest::SHA512.new
else
unsupported_algorithm = true
Digest::SHA1.new
end
algorithm_instance =
case algorithm
when "sha1"
-> { Digest::SHA1.new }
when "sha256"
-> { Digest::SHA256.new }
when "sha512"
-> { Digest::SHA512.new }
else
unsupported_algorithm = true
-> { Digest::SHA1.new }
end

# the tarball_url is absolute and can point to an entirely different domain
# so we need to find the right client pool for it
Expand All @@ -103,7 +104,7 @@ struct Commands::Install::Protocol::Registry::Resolver < Commands::Install::Prot
client.get("/" + relative_url) do |response|
raise "Invalid status code from #{tarball_url} (#{response.status_code})" unless response.status_code == 200

IO::Digest.new(response.body_io, algorithm_instance).tap do |io|
IO::Digest.new(response.body_io, algorithm_instance.call).tap do |io|
state.store.unpack_and_store_tarball(metadata, io)

io.skip_to_end
Expand Down
2 changes: 1 addition & 1 deletion packages/core/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct Core::Config
{% end %}
)
@[Env]
getter network_concurrency : Int32 = 50
getter network_concurrency : Int32 = 15
@[Env]
getter lockfile_format : Data::Lockfile::Format? = nil

Expand Down
2 changes: 1 addition & 1 deletion packages/workspaces/workspaces.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Workspaces
workspaces_field = workspaces_field["packages"]
end

return if workspaces_field.nil?
return if workspaces_field.nil? || workspaces_field.empty?

#################
# Gitignore rules from: https://git-scm.com/docs/gitignore
Expand Down

0 comments on commit b0e38b6

Please sign in to comment.