Commit 33a03a9b authored by Fabio Pelosin's avatar Fabio Pelosin

[SourcesManager] Search robustness.

Closes #929
parent 419a524e
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
###### Bug fixes ###### Bug fixes
* Fix crash related to the specification of the workspace as a relative path. * Fix crash related to the specification of the workspace as a relative path.
[#917](https://github.com/CocoaPods/CocoaPods/issues/920) [#920](https://github.com/CocoaPods/CocoaPods/issues/920)
* Fix crash related to search from the command line.
[#929](https://github.com/CocoaPods/CocoaPods/issues/929)
###### Ancillary enhancements ###### Ancillary enhancements
......
...@@ -95,10 +95,14 @@ module Pod ...@@ -95,10 +95,14 @@ module Pod
def updated_search_index def updated_search_index
if search_index_path.exist? if search_index_path.exist?
stored_index = YAML.load(search_index_path.read) stored_index = YAML.load(search_index_path.read)
if stored_index && stored_index.is_a?(Hash)
search_index = aggregate.update_search_index(stored_index) search_index = aggregate.update_search_index(stored_index)
else else
search_index = aggregate.generate_search_index search_index = aggregate.generate_search_index
end end
else
search_index = aggregate.generate_search_index
end
File.open(search_index_path, 'w') {|f| f.write(search_index.to_yaml) } File.open(search_index_path, 'w') {|f| f.write(search_index.to_yaml) }
search_index search_index
......
...@@ -59,7 +59,7 @@ module Pod ...@@ -59,7 +59,7 @@ module Pod
end end
it "updates the search index before performing a search if it exits" do it "updates the search index before performing a search if it exits" do
FileUtils.touch(SourcesManager.search_index_path) File.open(SourcesManager.search_index_path, 'w') { |file| file.write("---\nBananaLib:\n version: 0.0.1") }
Source::Aggregate.any_instance.stubs(:all).returns([@test_source]) Source::Aggregate.any_instance.stubs(:all).returns([@test_source])
Source::Aggregate.any_instance.expects(:generate_search_index).never Source::Aggregate.any_instance.expects(:generate_search_index).never
Source::Aggregate.any_instance.expects(:update_search_index).returns({'BananaLib' => {}}) Source::Aggregate.any_instance.expects(:update_search_index).returns({'BananaLib' => {}})
......
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