# class Chef::CookbookCacheCleaner

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.

### Public Class Methods

new() click to toggle source

    # File lib/chef/cookbook/synchronizer.rb, line 25
    def initialize
      reset!
    end

### Public Instance Methods

cache() click to toggle source

    # File lib/chef/cookbook/synchronizer.rb, line 37
    def cache
      Chef::FileCache
    end

cleanup_file_cache() click to toggle source

    # File lib/chef/cookbook/synchronizer.rb, line 41
    def cleanup_file_cache
      unless Chef::Config[:solo]
        # Delete each file in the cache that we didn't encounter in the
        # manifest.
        cache.find(File.join(%w{cookbooks ** *})).each do |cache_filename|
          unless @valid_cache_entries[cache_filename]
            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

mark_file_as_valid(cache_path) click to toggle source

    # File lib/chef/cookbook/synchronizer.rb, line 33
    def mark_file_as_valid(cache_path)
      @valid_cache_entries[cache_path] = true
    end

reset!() click to toggle source

    # File lib/chef/cookbook/synchronizer.rb, line 29
    def reset!
      @valid_cache_entries = {}
    end