cleanup: display total disk space to be cleared

Closes Homebrew/homebrew#45642.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Rakesh 2015-11-17 16:51:56 +05:30 committed by Mike McQuaid
parent e4f2a1e0ef
commit 090b133a01

View File

@ -2,8 +2,15 @@ require "formula"
require "keg" require "keg"
require "bottles" require "bottles"
require "thread" require "thread"
require "utils"
module Homebrew module Homebrew
@@disk_cleanup_size = 0
def update_disk_cleanup_size(path_size)
@@disk_cleanup_size += path_size
end
def cleanup def cleanup
if ARGV.named.empty? if ARGV.named.empty?
cleanup_cellar cleanup_cellar
@ -16,6 +23,15 @@ module Homebrew
else else
ARGV.resolved_formulae.each { |f| cleanup_formula(f) } ARGV.resolved_formulae.each { |f| cleanup_formula(f) }
end 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 end
def cleanup_logs def cleanup_logs
@ -113,6 +129,7 @@ module Homebrew
puts "Removing: #{path}... (#{path.abv})" puts "Removing: #{path}... (#{path.abv})"
yield yield
end end
update_disk_cleanup_size(path.disk_usage)
end end
def cleanup_lockfiles def cleanup_lockfiles