diff options
author | sersut <serdar@opscode.com> | 2013-10-03 15:05:23 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2013-10-03 15:05:23 -0700 |
commit | 5807c3b13568bd9bb12ccd1fad18bbb2bf196e96 (patch) | |
tree | b1d296d88178e219dbd61e18a481b471c66f721f /lib/chef/chef_fs/file_system | |
parent | cfe3944ee3dfa856c5eb43a3edafc45119d3d01b (diff) | |
download | chef-5807c3b13568bd9bb12ccd1fad18bbb2bf196e96.tar.gz |
Use symlink while uploading multiple versions of cookbooks.
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 |