Commit f799b5ce authored by Fabio Pelosin's avatar Fabio Pelosin

[Installer] Speed up downloads (cocoapods-downloader)

parent 1a943d72
......@@ -23,8 +23,6 @@ module Pod
:new_version_message => true,
:cache_root => Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods')),
:max_cache_size => 500,
:aggressive_cache => false,
}
public
......@@ -77,10 +75,6 @@ module Pod
# @!group Cache
# @return [Fixnum] The maximum size for the cache expressed in Mb.
#
attr_accessor :max_cache_size
# @return [Pathname] The directory where CocoaPods should cache remote data
# and other expensive to compute information.
#
......@@ -91,21 +85,6 @@ module Pod
@cache_root
end
# Allows to set whether the downloader should use more aggressive caching
# options.
#
# @note The aggressive cache has lead to issues if a tag is updated to
# point to another commit.
#
attr_writer :aggressive_cache
# @return [Bool] Whether the downloader should use more aggressive caching
# options.
#
def aggressive_cache?
@aggressive_cache || (ENV['CP_AGGRESSIVE_CACHE'] == 'TRUE')
end
public
#-------------------------------------------------------------------------#
......@@ -267,17 +246,6 @@ module Pod
# @!group Dependency Injection
# @return [Downloader] The downloader to use for the retrieving remote
# source.
#
def downloader(target_path, options)
downloader = Downloader.for_target(target_path, options)
downloader.cache_root = cache_root
downloader.max_cache_size = max_cache_size
downloader.aggressive_cache = aggressive_cache?
downloader
end
# @return [Specification::Set::Statistics] The statistic provider to use
# for specifications.
#
......
......@@ -101,7 +101,7 @@ module Pod
UI.titled_section(title, { :verbose_prefix => "-> " }) do
target = sandbox.root + name
target.rmtree if target.exist?
downloader = Config.instance.downloader(target, params)
downloader = Downloader.for_target(target, params)
downloader.download
store_podspec(sandbox, target + "#{name}.podspec")
sandbox.store_pre_downloaded_pod(name)
......
......@@ -288,7 +288,6 @@ module Pod
@pod_installers ||= []
pod_installer = PodSourceInstaller.new(sandbox, specs_by_platform)
pod_installer.aggressive_cache = config.aggressive_cache?
pod_installer.install!
@pod_installers << pod_installer
@installed_specs.concat(specs_by_platform.values.flatten.uniq)
......
......@@ -25,8 +25,6 @@ module Pod
def initialize(sandbox, specs_by_platform)
@sandbox = sandbox
@specs_by_platform = specs_by_platform
@aggressive_cache = false
end
# @return [String] A string suitable for debugging.
......@@ -39,21 +37,6 @@ module Pod
public
# @!group Configuration
# @return [Bool] whether the downloader should always check against the
# remote if issues might be generated (mostly useful to speed up
# testing).
#
# @note This might be removed in future.
#
attr_accessor :aggressive_cache
alias_method :aggressive_cache?, :aggressive_cache
#-----------------------------------------------------------------------#
public
# @!group Installation
# Creates the target in the Pods project and the relative support files.
......@@ -167,7 +150,7 @@ module Pod
# source.
#
def downloader
@downloader ||= Config.instance.downloader(root, root_spec.source.dup)
@downloader ||= Downloader.for_target(root, root_spec.source.dup)
end
#-----------------------------------------------------------------------#
......
......@@ -32,13 +32,6 @@ module Pod
@sut.default_test_podfile_path.should == Pathname.new("~/.cocoapods/templates/Podfile.test").expand_path
end
it "allows to specify whether the aggressive cache should be used with an environment variable" do
@sut.aggressive_cache = false
ENV['CP_AGGRESSIVE_CACHE'] = 'TRUE'
@sut.aggressive_cache?.should.be.true
ENV.delete('CP_AGGRESSIVE_CACHE')
end
it "allows to specify the home dir with an environment variable" do
ENV['CP_HOME_DIR'] = '~/custom_home_dir'
@sut.home_dir.should == Pathname.new("~/custom_home_dir").expand_path
......@@ -154,33 +147,15 @@ module Pod
@sut.should.clean
end
it "has a default cache size of 500" do
@sut.max_cache_size.should == 500
end
it "returns the cache root" do
@sut.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
end
it "doesn't use aggressive cache" do
@sut.should.not.aggressive_cache?
end
end
#-------------------------------------------------------------------------#
describe "Dependency Injection" do
it "returns the downloader" do
downloader = @sut.downloader(Pathname.new(''), { :git => 'example.com' })
downloader.target_path.should == Pathname.new('')
downloader.url.should == 'example.com'
downloader.cache_root.should == @sut.cache_root
downloader.max_cache_size.should == 500
downloader.aggressive_cache.should.be.false
end
it "returns the specification statistics provider" do
stats_provider = @sut.spec_statistics_provider
stats_provider.cache_file.should == @sut.cache_root + 'statistics.yml'
......
......@@ -12,16 +12,6 @@ module Pod
#-------------------------------------------------------------------------#
describe "In General" do
it "doesn't use an aggressive cache by default" do
@installer.should.not.aggressive_cache?
end
end
#-------------------------------------------------------------------------#
describe "Installation" do
describe "Download" do
......@@ -33,7 +23,7 @@ module Pod
pod_folder.should.exist
end
it "downloads the head source if specified source" do
it "downloads the head source even if a specific source is present specified source" do
config.sandbox.store_head_pod('BananaLib')
@spec.source = { :git => SpecHelper.fixture('banana-lib'), :tag => 'v1.0' }
@installer.install!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment