diff --git a/lib/cask/cli/cleanup.rb b/lib/cask/cli/cleanup.rb index 4d2ac5ce30..3de2664328 100644 --- a/lib/cask/cli/cleanup.rb +++ b/lib/cask/cli/cleanup.rb @@ -49,6 +49,11 @@ class Cask::CLI::Cleanup cache_incompletes(outdated) + cache_completes(outdated) end + def self.space_in_megs(files) + bytes = files.map { |f| begin File.size(f); rescue; 0; end }.reduce(&:+) || 0 + sprintf '%0.2f', bytes / (1024.0 * 1024.0) + end + def self.remove_dead_symlinks ohai "Removing dead symlinks" to_delete = dead_symlinks diff --git a/lib/cask/cli/doctor.rb b/lib/cask/cli/doctor.rb index 483d5cc35e..3c106774ac 100644 --- a/lib/cask/cli/doctor.rb +++ b/lib/cask/cli/doctor.rb @@ -11,6 +11,7 @@ class Cask::CLI::Doctor ohai 'Homebrew Origin:', render_with_none_as_error( homebrew_origin ) ohai 'Homebrew-cask Version:', render_with_none_as_error( HOMEBREW_CASK_VERSION ) ohai 'Homebrew-cask Install Location:', render_install_location( HOMEBREW_CASK_VERSION ) + ohai 'Homebrew-cask Cached Downloads:', render_cached_downloads ohai 'Homebrew-cask Default Tap Path:', render_tap_paths( fq_default_tap ) ohai 'Homebrew-cask Alternate Cask Taps:', render_tap_paths( alt_taps ) ohai 'Homebrew-cask Default Tap Cask Count:', render_with_none_as_error( default_cask_count ) @@ -160,6 +161,18 @@ class Cask::CLI::Doctor copy end + def self.render_cached_downloads + files = Cask::CLI::Cleanup.all_cache_files + count = files.count + space = Cask::CLI::Cleanup.space_in_megs files + [ + HOMEBREW_CACHE, + HOMEBREW_CACHE_CASKS, + count.to_s.concat(" files").concat(count == 0 ? '' : %Q{ #{error_string %Q{warning: run "brew cask cleanup"}}}), + space.to_s.concat(" megs").concat(count == 0 ? '' : %Q{ #{error_string %Q{warning: run "brew cask cleanup"}}}), + ] + end + def self.help "checks for configuration issues" end