detect cached downloads in doctor

and recommend "brew cask cleanup" if present.

Closes #4857
This commit is contained in:
Roland Walker
2014-06-19 14:51:32 -04:00
parent f65d422b82
commit bfc07561e5
2 changed files with 18 additions and 0 deletions
+5
View File
@@ -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
+13
View File
@@ -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