Sha256: 99e701cb757853006007973e132050b28959af703eedff2e2682490ebefd1aa1

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

require 'find'

class Admin::CacheController < Admin::BaseController
  def show
    @cache_size = 0
    @cache_number = 0

    FileUtils.mkdir_p(Rails.application.config.action_controller.page_cache_directory) unless File.exist?(Rails.application.config.action_controller.page_cache_directory)

    Find.find(Rails.application.config.action_controller.page_cache_directory) do |path|
      if FileTest.directory?(path)
        if File.basename(path)[0] == '.'
          Find.prune
        else
          next
        end
      else
        @cache_size += FileTest.size(path)
        @cache_number += 1
      end
    end
  end

  def destroy
    begin
      PageCache.sweep_all
      flash[:success] = t('admin.cache.destroy.success')
    rescue
      flash[:error] = t('admin.cache.destroy.error')
    end
    redirect_to admin_cache_url
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
publify_core-9.0.0.pre2 app/controllers/admin/cache_controller.rb
publify_core-9.0.0.pre1 app/controllers/admin/cache_controller.rb