Commit e9642d7c authored by Alex Rothenberg's avatar Alex Rothenberg

Cleanup pod directory when download fails (probably due to a network error)

Fixes #1482
parent b09f0dae
...@@ -63,6 +63,10 @@ module Pod ...@@ -63,6 +63,10 @@ module Pod
def install! def install!
download_source unless predownloaded? || local? download_source unless predownloaded? || local?
run_prepare_command run_prepare_command
rescue => e
UI.notice("Error installing #{root_spec.name}")
clean!
raise
end end
# Cleans the installations if appropriate. # Cleans the installations if appropriate.
......
...@@ -61,6 +61,23 @@ module Pod ...@@ -61,6 +61,23 @@ module Pod
} }
end end
it "cleans up directory when an error occurs during download" do
config.sandbox.store_head_pod('BananaLib')
pod_folder = config.sandbox.root + 'BananaLib'
partially_downloaded_file = pod_folder + 'partially_downloaded_file'
mock_downloader = Object.new
mock_downloader.define_singleton_method(:download_head) do
FileUtils.mkdir_p(pod_folder)
FileUtils.touch(partially_downloaded_file)
raise("some network error")
end
@installer.stubs(:downloader).returns(mock_downloader)
lambda {
@installer.install!
}.should.raise(RuntimeError).message.should.equal('some network error')
partially_downloaded_file.should.not.exist
end
end end
#--------------------------------------# #--------------------------------------#
......
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