Commit 2e117f9f authored by Marius Rackwitz's avatar Marius Rackwitz

Merge pull request #3561 from CocoaPods/mr-fix-incomplete-cache

[Cache] Recognize incomplete cache for released pods
parents ffa8b8a6 3c7c2d8b
...@@ -12,6 +12,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -12,6 +12,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Boris Bügling](https://github.com/neonichu) [Boris Bügling](https://github.com/neonichu)
[#3600](https://github.com/CocoaPods/CocoaPods/issues/3600) [#3600](https://github.com/CocoaPods/CocoaPods/issues/3600)
* Recognizes incomplete cache when the original download of a pod was
interrupted.
[Marius Rackwitz](https://github.com/mrackwitz)
[#3561](https://github.com/CocoaPods/CocoaPods/issues/3561)
* Allow opting out of pod source locking, meaning `pod try` yields editable * Allow opting out of pod source locking, meaning `pod try` yields editable
projects. projects.
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
......
...@@ -76,9 +76,10 @@ module Pod ...@@ -76,9 +76,10 @@ module Pod
# was found in the download cache. # was found in the download cache.
# #
def cached_pod(request) def cached_pod(request)
cached_spec = cached_spec(request)
path = path_for_pod(request) path = path_for_pod(request)
spec = request.spec || cached_spec(request) return unless cached_spec && path.directory?
return unless spec && path.directory? spec = request.spec || cached_spec
Response.new(path, spec, request.params) Response.new(path, spec, request.params)
end end
...@@ -91,6 +92,8 @@ module Pod ...@@ -91,6 +92,8 @@ module Pod
def cached_spec(request) def cached_spec(request)
path = path_for_spec(request) path = path_for_spec(request)
path.file? && Specification.from_file(path) path.file? && Specification.from_file(path)
rescue JSON::ParserError
nil
end end
# @param [Request] request # @param [Request] request
......
...@@ -74,6 +74,53 @@ module Pod ...@@ -74,6 +74,53 @@ module Pod
end end
end end
describe 'when the cache is incomplete' do
shared 'it falls back to download the pod' do
describe 'when downloading a released pod' do
it 'does download the source' do
Downloader::Git.any_instance.expects(:download).never
@cache.expects(:uncached_pod).once
@cache.download_pod(@request)
end
end
describe 'when downloading an unreleased pod' do
it 'does download the source' do
Downloader::Git.any_instance.expects(:download).never
@cache.expects(:uncached_pod).once
@cache.download_pod(@unreleased_request)
end
end
end
before do
[@request, @unreleased_request].each do |request|
path_for_pod = @cache.send(:path_for_pod, request)
path_for_pod.mkpath
Dir.chdir(path_for_pod) do
FileUtils.mkdir_p 'Classes'
File.open('Classes/a.m', 'w') {}
end
end
end
describe 'because the spec is missing' do
behaves_like 'it falls back to download the pod'
end
describe 'because the spec is invalid' do
before do
[@request, @unreleased_request].each do |request|
path_for_spec = @cache.send(:path_for_spec, request)
path_for_spec.dirname.mkpath
path_for_spec.open('w') { |f| f << '{' }
end
end
behaves_like 'it falls back to download the pod'
end
end
describe 'when the download is cached' do describe 'when the download is cached' do
before do before do
[@request, @unreleased_request].each do |request| [@request, @unreleased_request].each do |request|
......
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