Skip to content

Commit

Permalink
Merge pull request #771 from esteluk/fix-multi-cdn
Browse files Browse the repository at this point in the history
Support multiple CDN sources
  • Loading branch information
amorde authored Jul 27, 2024
2 parents d9cdb56 + fd71c21 commit ffea754
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
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

0 comments on commit ffea754

Please sign in to comment.