    # File lib/chef/cookbook_version.rb, line 353
        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)

          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
              #
              # We need the list of known good attribute files, so we can delete any that are
              # just laying about.

              cache_filename = File.join("cookbooks", cookbook.name, manifest_record['path'])
              valid_cache_entries[cache_filename] = true

              current_checksum = nil
              if cache.has_key?(cache_filename)
                current_checksum = checksum_cookbook_file(cache.load(cache_filename, false))
              end

              # If the checksums are different between on-disk (current) and on-server
              # (remote, per manifest), do the update. This will also execute if there
              # is no current checksum.
              if current_checksum != manifest_record['checksum']
                raw_file = chef_server_rest.get_rest(manifest_record[:url], true)

                Chef::Log.info("Storing updated #{cache_filename} in the cache.")
                cache.move_to(raw_file.path, cache_filename)
              else
                Chef::Log.debug("Not storing #{cache_filename}, as the cache is up to date.")
              end

              # make the segment filenames a full path.
              full_path_cache_filename = cache.load(cache_filename, false)
              segment_filenames << full_path_cache_filename
            end

            # replace segment filenames with a full-path one.
            if segment.to_sym == :recipes
              cookbook.recipe_filenames = segment_filenames
            elsif segment.to_sym == :attributes
              cookbook.attribute_filenames = segment_filenames
            else
              cookbook.segment_filenames(segment).replace(segment_filenames)
            end
          end
        end