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.
This commit is contained in:
parent
2fc88ae247
commit
e49a043401
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user