Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
eee0d344
Commit
eee0d344
authored
May 06, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Downloader] Actually allow skipping the cache entirely
parent
5f065df1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
53 deletions
+98
-53
CHANGELOG.md
CHANGELOG.md
+4
-0
downloader.rb
lib/cocoapods/downloader.rb
+80
-5
cache.rb
lib/cocoapods/downloader/cache.rb
+4
-44
cache_spec.rb
spec/unit/downloader/cache_spec.rb
+10
-4
No files found.
CHANGELOG.md
View file @
eee0d344
...
...
@@ -41,6 +41,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
avoids an incomplete module map warning.
[
Samuel Giddins
](
https://github.com/segiddins
)
*
Actually allow skipping the download cache by downloading directly to the
download target when requested.
[
Samuel Giddins
](
https://github.com/segiddins
)
## 0.37.0
...
...
lib/cocoapods/downloader.rb
View file @
eee0d344
...
...
@@ -27,22 +27,97 @@ module Pod
def
self
.
download
(
request
,
target
,
cache_path:
!
Config
.
instance
.
skip_download_cache
&&
Config
.
instance
.
cache_root
+
'Pods'
cache_path:
!
Config
.
instance
.
skip_download_cache
&&
Config
.
instance
.
c
lean?
&&
Config
.
instance
.
c
ache_root
+
'Pods'
)
cache_path
,
tmp_cache
=
Pathname
(
Dir
.
mktmpdir
),
true
unless
cache_path
if
cache_path
cache
=
Cache
.
new
(
cache_path
)
result
=
cache
.
download_pod
(
request
)
if
target
&&
result
.
location
else
result
,
_
=
download_request
(
request
,
target
)
end
if
target
&&
result
.
location
&&
target
!=
result
.
location
UI
.
message
"Copying
#{
request
.
name
}
from `
#{
result
.
location
}
` to
#{
UI
.
path
target
}
"
,
'> '
do
FileUtils
.
rm_rf
target
FileUtils
.
cp_r
(
result
.
location
,
target
)
end
end
result
ensure
FileUtils
.
rm_r
cache_path
if
tmp_cache
end
# Performs the download from the given `request` to the given `target` location.
#
# @return [Response, Hash<String,Specification>]
# The download response for this download, and the specifications
# for this download grouped by name.
#
# @param [Request] request
# the request that describes this pod download.
#
# @param [Pathname,Nil] target
# the location to which this pod should be downloaded. If `nil`,
# then the pod will only be cached.
#
def
self
.
download_request
(
request
,
target
)
result
=
Response
.
new
result
.
checkout_options
=
download_source
(
request
.
name
,
target
,
request
.
params
,
request
.
head?
)
result
.
location
=
target
if
request
.
released_pod?
result
.
spec
=
request
.
spec
podspecs
=
{
request
.
name
=>
request
.
spec
}
else
podspecs
=
Sandbox
::
PodspecFinder
.
new
(
target
).
podspecs
podspecs
[
request
.
name
]
=
request
.
spec
if
request
.
spec
podspecs
.
each
do
|
name
,
spec
|
if
request
.
name
==
name
result
.
spec
=
spec
end
end
end
[
result
,
podspecs
]
end
private
# Downloads a pod with the given `name` and `params` to `target`.
#
# @param [String] name
#
# @param [Pathname] target
#
# @param [Hash<Symbol,String>] params
#
# @param [Boolean] head
#
# @return [Hash] The checkout options required to re-download this exact
# same source.
#
def
self
.
download_source
(
name
,
target
,
params
,
head
)
FileUtils
.
rm_rf
(
target
)
downloader
=
Downloader
.
for_target
(
target
,
params
)
if
head
unless
downloader
.
head_supported?
raise
Informative
,
"The pod '
#{
name
}
' does not "
\
"support the :head option, as it uses a
#{
downloader
.
name
}
"
\
'source. Remove that option to use this pod.'
end
downloader
.
download_head
else
downloader
.
download
end
target
.
mkpath
if
downloader
.
options_specific?
&&
!
head
params
else
downloader
.
checkout_options
end
end
public
class
DownloaderError
;
include
CLAide
::
InformativeError
;
end
class
Base
...
...
lib/cocoapods/downloader/cache.rb
View file @
eee0d344
...
...
@@ -99,25 +99,14 @@ module Pod
#
def
uncached_pod
(
request
)
in_tmpdir
do
|
target
|
result
=
Response
.
new
result
.
checkout_options
=
download
(
request
.
name
,
target
,
request
.
params
,
request
.
head?
)
if
request
.
released_pod?
result
.
spec
=
request
.
spec
result
.
location
=
destination
=
path_for_pod
(
request
,
:params
=>
result
.
checkout_options
)
copy_and_clean
(
target
,
destination
,
request
.
spec
)
write_spec
(
request
.
spec
,
path_for_spec
(
request
,
:params
=>
result
.
checkout_options
))
else
podspecs
=
Sandbox
::
PodspecFinder
.
new
(
target
).
podspecs
podspecs
[
request
.
name
]
=
request
.
spec
if
request
.
spec
result
,
podspecs
=
download
(
request
,
target
)
podspecs
.
each
do
|
name
,
spec
|
destination
=
path_for_pod
(
request
,
:name
=>
name
,
:params
=>
result
.
checkout_options
)
copy_and_clean
(
target
,
destination
,
spec
)
write_spec
(
spec
,
path_for_spec
(
request
,
:name
=>
name
,
:params
=>
result
.
checkout_options
))
if
request
.
name
==
name
result
.
location
=
destination
result
.
spec
=
spec
end
end
end
...
...
@@ -125,37 +114,8 @@ module Pod
end
end
# Downloads a pod with the given `name` and `params` to `target`.
#
# @param [String] name
#
# @param [Pathname] target
#
# @param [Hash<Symbol,String>] params
#
# @param [Boolean] head
#
# @return [Hash] The checkout options required to re-download this exact
# same source.
#
def
download
(
name
,
target
,
params
,
head
)
downloader
=
Downloader
.
for_target
(
target
,
params
)
if
head
unless
downloader
.
head_supported?
raise
Informative
,
"The pod '
#{
name
}
' does not "
\
"support the :head option, as it uses a
#{
downloader
.
name
}
"
\
'source. Remove that option to use this pod.'
end
downloader
.
download_head
else
downloader
.
download
end
if
downloader
.
options_specific?
&&
!
head
params
else
downloader
.
checkout_options
end
def
download
(
request
,
target
)
Downloader
.
download_request
(
request
,
target
)
end
# Performs the given block inside a temporary directory,
...
...
spec/unit/downloader/cache_spec.rb
View file @
eee0d344
...
...
@@ -8,10 +8,16 @@ module Pod
@spec
.
source
=
{
:git
=>
SpecHelper
.
fixture
(
'banana-lib'
)
}
@request
=
Downloader
::
Request
.
new
(
:spec
=>
@spec
,
:released
=>
true
)
@unreleased_request
=
Downloader
::
Request
.
new
(
:name
=>
'BananaLib'
,
:params
=>
@spec
.
source
)
@stub_download
=
lambda
do
|
cache
,
&
blk
|
cache
.
define_singleton_method
(
:download
)
do
|
_name
,
target
,
_params
,
_head
|
@stub_download
=
lambda
do
|&
blk
|
original_download_source
=
Downloader
.
method
(
:download_source
)
Downloader
.
define_singleton_method
(
:download_source
)
do
|
_name
,
target
,
_params
,
_head
|
FileUtils
.
mkdir_p
target
Dir
.
chdir
(
target
)
{
blk
.
call
}
Dir
.
chdir
(
target
)
do
result
=
blk
.
call
Downloader
.
define_singleton_method
(
:download_source
,
original_download_source
)
result
end
end
end
end
...
...
@@ -53,7 +59,7 @@ module Pod
describe
'when downloading an un-released pod'
do
before
do
@stub_download
.
call
@cache
do
@stub_download
.
call
do
File
.
open
(
'BananaLib.podspec.json'
,
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
}
File
.
open
(
'OrangeLib.podspec.json'
,
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
.
sub
(
/"name": "BananaLib"/
,
'"name": "OrangeLib"'
)
}
@spec
.
source
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment