summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Tolstov <v.tolstov@selfip.ru>2014-11-11 22:10:54 +0300
committerLamont Granquist <lamont@scriptkiddie.org>2014-11-13 12:39:14 -0800
commite6d0a0ea72bc982ac294d64764efa4f1d6da0e66 (patch)
treec51727d76d6a3dcc8ee90a6e5f8baba0343a3c85
parentd80796160625016889ded0ce42fec3ea9945e39e (diff)
downloadchef-e6d0a0ea72bc982ac294d64764efa4f1d6da0e66.tar.gz
cleanup cookbook path from stale files
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
-rw-r--r--lib/chef/application/solo.rb2
-rw-r--r--spec/unit/application/solo_spec.rb2
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 474bbf3f6c..c99170f437 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -191,6 +191,8 @@ class Chef::Application::Solo < Chef::Application
cookbooks_path = Array(Chef::Config[:cookbook_path]).detect{|e| e =~ /\/cookbooks\/*$/ }
recipes_path = File.expand_path(File.join(cookbooks_path, '..'))
+ Chef::Log.debug "Cleanup path #{recipes_path} before extract recipes into it"
+ FileUtils.rm_rf(recipes_path, :secure => true)
Chef::Log.debug "Creating path #{recipes_path} to extract recipes into"
FileUtils.mkdir_p(recipes_path)
tarball_path = File.join(recipes_path, 'recipes.tgz')
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 26d7d34caa..80f0bead8b 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -94,6 +94,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
before do
Chef::Config[:cookbook_path] = "#{Dir.tmpdir}/chef-solo/cookbooks"
Chef::Config[:recipe_url] = "http://junglist.gen.nz/recipes.tgz"
+ allow(FileUtils).to receive(:rm_rf).and_return(true)
allow(FileUtils).to receive(:mkdir_p).and_return(true)
@tarfile = StringIO.new("remote_tarball_content")
allow(@app).to receive(:open).with("http://junglist.gen.nz/recipes.tgz").and_yield(@tarfile)
@@ -135,6 +136,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
Chef::Config[:json_attribs] = json_source
Chef::Config[:recipe_url] = "http://icanhas.cheezburger.com/lolcats"
Chef::Config[:cookbook_path] = "#{Dir.tmpdir}/chef-solo/cookbooks"
+ allow(FileUtils).to receive(:rm_rf).and_return(true)
allow(FileUtils).to receive(:mkdir_p).and_return(true)
allow(Chef::Mixin::Command).to receive(:run_command).and_return(true)
end