Method: RGen::Util::FileCacheMap#clean_unused
- Defined in:
- lib/rgen/util/file_cache_map.rb
#clean_unused(root_path, key_paths) ⇒ Object
remove cache files which are not associated with any file in key_paths will only remove files within root_path
80 81 82 83 84 85 86 87 |
# File 'lib/rgen/util/file_cache_map.rb', line 80 def clean_unused(root_path, key_paths) raise "key paths must be within root path" unless key_paths.all?{|p| p.index(root_path) == 0} used_files = key_paths.collect{|p| cache_file(p)} files = Dir[root_path+"/**/"+@cache_dir+"/*"+@postfix] files.each do |f| FileUtils.rm(f) unless used_files.include?(f) end end |