lib/chef/cookbook_version.rb in chef-10.12.0 vs lib/chef/cookbook_version.rb in chef-10.14.0.beta.1

- old
+ new

@@ -18,11 +18,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'chef/log' -require 'chef/client' require 'chef/node' require 'chef/resource_definition_list' require 'chef/recipe' require 'chef/cookbook/file_vendor' require 'chef/checksum' @@ -102,10 +101,11 @@ raise "Unexpected comparison to #{o}" unless o.respond_to?(:legit_version) legit_version <=> o.legit_version end end + # == Chef::CookbookVersion # CookbookVersion is a model object encapsulating the data about a Chef # cookbook. Chef supports maintaining multiple versions of a cookbook on a # single server; each version is represented by a distinct instance of this # class. @@ -282,32 +282,14 @@ rescue Errno::ENOENT Chef::Log.debug("File #{filepath} does not exist, so there is no checksum to generate") nil end - # Keep track of the filenames that we use in both eager cookbook - # downloading (during sync_cookbooks) and lazy (during the run - # itself, through FileVendor). After the run is over, clean up the - # cache. - def self.valid_cache_entries - @valid_cache_entries ||= {} - end - - def self.reset_cache_validity - @valid_cache_entries = nil - end - def self.cache Chef::FileCache end - # Setup a notification to clear the valid_cache_entries when a Chef client - # run starts - Chef::Client.when_run_starts do |run_status| - reset_cache_validity - end - # Synchronizes all the cookbooks from the chef-server. # # === Returns # true:: Always returns true def self.sync_cookbooks(cookbook_hash) @@ -349,13 +331,16 @@ def self.sync_cookbook_file_cache(cookbook) Chef::Log.debug("Synchronizing cookbook #{cookbook.name}") # files and templates are lazily loaded, and will be done later. eager_segments = COOKBOOK_SEGMENTS.dup - eager_segments.delete(:files) - eager_segments.delete(:templates) + unless Chef::Config[:no_lazy_load] then + eager_segments.delete(:files) + eager_segments.delete(:templates) + end + eager_segments.each do |segment| segment_filenames = Array.new cookbook.manifest[segment].each do |manifest_record| # segment = cookbook segment # remote_list = list of file hashes @@ -408,14 +393,9 @@ Chef::Log.info("Removing #{cache_filename} from the cache; it is no longer needed by chef-client.") cache.delete(cache_filename) end end end - end - - # Register a notification to cleanup unused files from cookbooks - Chef::Client.when_run_completes_successfully do |run_status| - cleanup_file_cache end # Creates a new Chef::CookbookVersion object. # # === Returns