aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMike McQuaid2015-08-13 10:22:28 +0100
committerMike McQuaid2015-08-13 10:22:28 +0100
commite49a0434014464488de356550ffaa6028666faf5 (patch)
tree1b40d20e0a7079d97bebb20d6c2345806e0e40e3 /Library/Homebrew/cmd
parent2fc88ae2479bee9ea955027383d1d71cabc8c497 (diff)
downloadbrew-e49a0434014464488de356550ffaa6028666faf5.tar.bz2
cleanup: remove more on --force or --prune.
Remove more logs, use the prune time period and remove version control checkouts when --force or --prune is used.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/cleanup.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index 157b40891..d90530058 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -23,9 +23,14 @@ module Homebrew
def cleanup_logs
return unless HOMEBREW_LOGS.directory?
- time = Time.now - 2 * 7 * 24 * 60 * 60 # two weeks
+ prune = ARGV.value "prune"
+ if prune
+ time = Time.now - 60 * 60 * 24 * prune.to_i
+ else
+ time = Time.now - 60 * 60 * 24 * 7 * 2 # two weeks
+ end
HOMEBREW_LOGS.subdirs.each do |dir|
- cleanup_path(dir) { dir.rmtree } if dir.mtime < time
+ cleanup_path(dir) { dir.rmtree } if ARGV.force? || (dir.mtime < time)
end
end
@@ -66,8 +71,18 @@ module Homebrew
return unless HOMEBREW_CACHE.directory?
prune = ARGV.value "prune"
time = Time.now - 60 * 60 * 24 * prune.to_i
- HOMEBREW_CACHE.children.select(&:file?).each do |file|
- next cleanup_path(file) { file.unlink } if prune && file.mtime < time
+ HOMEBREW_CACHE.children.each do |path|
+ if ARGV.force? || (prune && path.mtime < time)
+ if path.file?
+ cleanup_path(path) { path.unlink }
+ elsif path.directory? && path.to_s.include?("--")
+ cleanup_path(path) { path.rmdir }
+ end
+ next
+ end
+
+ next unless path.file?
+ file = path
if Pathname::BOTTLE_EXTNAME_RX === file.to_s
version = bottle_resolve_version(file) rescue file.version