Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple CDN sources #771

Merged
merged 4 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
os: [ubuntu-20.04]
ruby: [2.6, 2.7, 3.0.0, 3.2.2]
include:
- os: macos-11
- os: macos-13
ruby: system

name: ${{ matrix.os }} / Ruby ${{ matrix.ruby }}
Expand Down
23 changes: 14 additions & 9 deletions lib/cocoapods-core/cdn_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def versions(name)
pod_path_actual = pod_path(name)
pod_path_relative = relative_pod_path(name)

return nil if @version_arrays_by_fragment_by_name[fragment][name].nil?
return nil if @version_arrays_by_fragment_by_name.dig(fragment, name).nil?

concurrent_requests_catching_errors do
loaders = []
Expand Down Expand Up @@ -282,14 +282,19 @@ def ensure_versions_file_loaded(fragment)
# We use those because you can't get a directory listing from a CDN.
index_file_name = index_file_name_for_fragment(fragment)
download_file(index_file_name)
versions_raw = local_file(index_file_name, &:to_a).map(&:chomp)
@version_arrays_by_fragment_by_name[fragment] = versions_raw.reduce({}) do |hash, row|
row = row.split('/')
pod = row.shift
versions = row

hash[pod] = versions
hash
file_okay = local_file_okay?(index_file_name)
if file_okay
versions_raw = local_file(index_file_name, &:to_a).map(&:chomp)
@version_arrays_by_fragment_by_name[fragment] = versions_raw.reduce({}) do |hash, row|
row = row.split('/')
pod = row.shift
versions = row

hash[pod] = versions
hash
end
else
debug "CDN: #{name} Relative path: #{index_file_name} not available in this source set"
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/cdn_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ def typhoeus_non_http_response_future(code)
end

it 'matches case' do
@source.expects(:debug).with { |cmd| cmd =~ /CDN: #{@source.name} Relative path: all_pods_versions_9_5_b\.txt not available in this source set/ }
@source.expects(:debug).with { |cmd| cmd =~ /CDN: #{@source.name} Relative path downloaded: all_pods_versions_9_5_b\.txt, save ETag:/ }
@source.search('bEacoNKIT').should.be.nil?
end
Expand Down