summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-06-30 15:47:46 -0700
committersersut <serdar@opscode.com>2014-07-01 09:32:37 -0700
commit3229b3b35c6e7da68598eb59ac1e50a7239fc078 (patch)
tree19fc7426a9e2dbaabeec295ff3062645523ac6d9 /lib
parent855b72b5803d525cf953b51ad1cd499c09a2bd37 (diff)
downloadchef-3229b3b35c6e7da68598eb59ac1e50a7239fc078.tar.gz
Do not update the path in the cookbook_manifest with the full file name.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/cookbook/synchronizer.rb37
1 files changed, 24 insertions, 13 deletions
diff --git a/lib/chef/cookbook/synchronizer.rb b/lib/chef/cookbook/synchronizer.rb
index 0e8f5e692e..7df3f554bb 100644
--- a/lib/chef/cookbook/synchronizer.rb
+++ b/lib/chef/cookbook/synchronizer.rb
@@ -68,6 +68,8 @@ class Chef
@eager_segments.freeze
@cookbooks_by_name, @events = cookbooks_by_name, events
+
+ @cookbook_full_file_paths = {}
end
def cache
@@ -136,14 +138,20 @@ class Chef
files.each do |file|
queue << lambda do |lock|
- sync_file(file)
- lock.synchronize { mark_file_synced(file) }
+ full_file_path = sync_file(file)
+
+ lock.synchronize {
+ # Save the full_path of the downloaded file to be restored in the manifest later
+ save_full_file_path(file, full_file_path)
+ mark_file_synced(file)
+ }
end
end
@events.cookbook_sync_start(cookbook_count)
queue.process(Chef::Config[:cookbook_sync_threads])
- update_cookbook_filenames
+ # Update the full file paths in the manifest
+ update_cookbook_filenames()
rescue Exception => e
@events.cookbook_sync_failed(cookbooks, e)
@@ -153,6 +161,14 @@ class Chef
true
end
+ # Saves the full_path to the file of the cookbook to be updated
+ # in the manifest later
+ def save_full_file_path(file, full_path)
+ @cookbook_full_file_paths[file.cookbook] ||= { }
+ @cookbook_full_file_paths[file.cookbook][file.segment] ||= [ ]
+ @cookbook_full_file_paths[file.cookbook][file.segment] << full_path
+ end
+
# Iterates over cached cookbooks' files, removing files belonging to
# cookbooks that don't appear in +cookbook_hash+
def clear_obsoleted_cookbooks
@@ -170,14 +186,9 @@ class Chef
end
def update_cookbook_filenames
- files_by_cookbook.each do |cookbook, cookbook_files|
- files_by_segment = cookbook_files.group_by { |file| file.segment }
- @eager_segments.each do |segment|
- segment_files = files_by_segment[segment]
- next unless segment_files
-
- filenames = segment_files.map { |file| file.manifest_record['path'] }
- cookbook.replace_segment_filenames(segment, filenames)
+ @cookbook_full_file_paths.each do |cookbook, file_segments|
+ file_segments.each do |segment, full_paths|
+ cookbook.replace_segment_filenames(segment, full_paths)
end
end
end
@@ -204,8 +215,8 @@ class Chef
Chef::Log.debug("Not storing #{cache_filename}, as the cache is up to date.")
end
- # Update the manifest with the full path to the cached file
- file.manifest_record['path'] = cache.load(cache_filename, false)
+ # Load the file in the cache and return the full file path to the loaded file
+ cache.load(cache_filename, false)
end
def cached_copy_up_to_date?(local_path, expected_checksum)