class ActiveSupport::Cache::FileStore

def delete_empty_directories(dir)

Delete empty directories in the cache.
def delete_empty_directories(dir)
  return if File.realpath(dir) == File.realpath(cache_path)
  if Dir.children(dir).empty?
    Dir.delete(dir) rescue nil
    delete_empty_directories(File.dirname(dir))
  end
end