diff options
Diffstat (limited to 'lib/chef/chef_fs/file_system')
-rw-r--r-- | lib/chef/chef_fs/file_system/cookbooks_dir.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/chef/chef_fs/file_system/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/cookbooks_dir.rb index e707216bf7..73684450b3 100644 --- a/lib/chef/chef_fs/file_system/cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/cookbooks_dir.rb @@ -22,6 +22,7 @@ require 'chef/chef_fs/raw_request' require 'chef/chef_fs/file_system/operation_failed_error' require 'chef/chef_fs/file_system/cookbook_frozen_error' require 'chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir' +require 'chef/mixin/file_class' require 'tmpdir' @@ -30,6 +31,8 @@ class Chef module FileSystem class CookbooksDir < RestListDir + include Chef::Mixin::FileClass + def initialize(parent) super("cookbooks", parent) end @@ -93,11 +96,10 @@ class Chef Dir.mktmpdir do |temp_cookbooks_path| proxy_cookbook_path = "#{temp_cookbooks_path}/#{cookbook_name}" - # symlinking fails on windows, so cp_r the whole directory - - FileUtils.cp_r(other.file_path, proxy_cookbook_path); + # Make a symlink + file_class.symlink other.file_path, proxy_cookbook_path - # Instantiate a proxy loader using the temporary directory + # Instantiate a proxy loader using the temporary symlink proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.parent.chefignore) proxy_loader.load_cookbooks @@ -110,6 +112,17 @@ class Chef with_actual_cookbooks_dir(temp_cookbooks_path) do upload_cookbook!(uploader) end + + # + # When the temporary directory is being deleted on + # windows, the contents of the symlink under that + # directory is also deleted. So explicitly remove + # the symlink without removing the original contents if we + # are running on windows + # + if Chef::Platform.windows? + Dir.rmdir proxy_cookbook_path + end end end |