cleanup: add --prune to delete old cache files.
This commit is contained in:
parent
e8c0d8ac20
commit
451a07cc4e
@ -66,7 +66,11 @@ module Homebrew
|
|||||||
|
|
||||||
def cleanup_cache
|
def cleanup_cache
|
||||||
return unless HOMEBREW_CACHE.directory?
|
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|
|
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 (version = file.version)
|
||||||
next unless (name = file.basename.to_s[/(.*)-(?:#{Regexp.escape(version)})/, 1])
|
next unless (name = file.basename.to_s[/(.*)-(?:#{Regexp.escape(version)})/, 1])
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ Note that these flags should only appear after a command.
|
|||||||
* `cat` <formula>:
|
* `cat` <formula>:
|
||||||
Display the source to <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
|
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
|
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
|
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 `--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 `-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
|
If `-s` is passed, scrubs the cache, removing downloads for even the latest
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
.
|
.
|
||||||
.TH "BREW" "1" "March 2015" "Homebrew" "brew"
|
.TH "BREW" "1" "April 2015" "Homebrew" "brew"
|
||||||
.
|
.
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
\fBbrew\fR \- The missing package manager for OS X
|
\fBbrew\fR \- The missing package manager for OS X
|
||||||
@ -61,13 +61,16 @@ If \fB\-\-strict\fR is passed, additional checks are run\. This should be used w
|
|||||||
Display the source to \fIformula\fR\.
|
Display the source to \fIformula\fR\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBcleanup [\-\-force] [\-ns]\fR [\fIformulae\fR]
|
\fBcleanup [\-\-force] [\-\-prune=<days>] [\-ns]\fR [\fIformulae\fR]
|
||||||
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 the Homebrew download\-cache are deleted\.
|
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 the Homebrew download\-cache are deleted\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
If \fB\-\-force\fR is passed, remove out\-of\-date keg\-only brews as well\.
|
If \fB\-\-force\fR is passed, remove out\-of\-date keg\-only brews as well\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
If \fB\-\-prune=<days>\fR is specified, remove all cache files older than \fIdays\fR\.
|
||||||
|
.
|
||||||
|
.IP
|
||||||
If \fB\-n\fR is passed, show what would be removed, but do not actually remove anything\.
|
If \fB\-n\fR is passed, show what would be removed, but do not actually remove anything\.
|
||||||
.
|
.
|
||||||
.IP
|
.IP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user