From 090b133a01d3918ea6a0d73768b836185a8dce35 Mon Sep 17 00:00:00 2001 From: Rakesh Date: Tue, 17 Nov 2015 16:51:56 +0530 Subject: [PATCH] cleanup: display total disk space to be cleared Closes Homebrew/homebrew#45642. Signed-off-by: Mike McQuaid --- Library/Homebrew/cmd/cleanup.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index 3439fd99a9..e01a809b59 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -2,8 +2,15 @@ require "formula" require "keg" require "bottles" require "thread" +require "utils" module Homebrew + @@disk_cleanup_size = 0 + + def update_disk_cleanup_size(path_size) + @@disk_cleanup_size += path_size + end + def cleanup if ARGV.named.empty? cleanup_cellar @@ -16,6 +23,15 @@ module Homebrew else ARGV.resolved_formulae.each { |f| cleanup_formula(f) } end + + if @@disk_cleanup_size > 0 + disk_space = disk_usage_readable(@@disk_cleanup_size) + if ARGV.dry_run? + ohai "This operation would free approximately #{disk_space} of disk space." + else + ohai "This operation has freed approximately #{disk_space} of disk space." + end + end end def cleanup_logs @@ -113,6 +129,7 @@ module Homebrew puts "Removing: #{path}... (#{path.abv})" yield end + update_disk_cleanup_size(path.disk_usage) end def cleanup_lockfiles