diff options
| author | Mike McQuaid | 2015-04-11 16:37:47 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2015-04-16 17:52:10 -0700 |
| commit | 451a07cc4e655b34f07d50f1dd45552d6c6d14b5 (patch) | |
| tree | 097c9f69c332128959677a15793c119b978ce58e /Library | |
| parent | e8c0d8ac20db69e48e1b1d87c51055fd0073c01e (diff) | |
| download | brew-451a07cc4e655b34f07d50f1dd45552d6c6d14b5.tar.bz2 | |
cleanup: add --prune to delete old cache files.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/cleanup.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/manpages/brew.1.md | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index e0f31d797..786c08275 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -66,7 +66,11 @@ module Homebrew def cleanup_cache 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 + next unless (version = file.version) next unless (name = file.basename.to_s[/(.*)-(?:#{Regexp.escape(version)})/, 1]) diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md index e155ac8b0..8f1f2b161 100644 --- a/Library/Homebrew/manpages/brew.1.md +++ b/Library/Homebrew/manpages/brew.1.md @@ -53,7 +53,7 @@ Note that these flags should only appear after a command. * `cat` <formula>: Display the source to <formula>. - * `cleanup [--force] [-ns]` [<formulae>]: + * `cleanup [--force] [--prune=<days>] [-ns]` [<formulae>]: For all installed or specific formulae, remove any older versions from the cellar. By default, does not remove out-of-date keg-only brews, as other software may link directly to specific versions. In addition old downloads from @@ -61,6 +61,8 @@ Note that these flags should only appear after a command. If `--force` is passed, remove out-of-date keg-only brews as well. + If `--prune=<days>` is specified, remove all cache files older than <days>. + If `-n` is passed, show what would be removed, but do not actually remove anything. If `-s` is passed, scrubs the cache, removing downloads for even the latest |
