cleanup: all configuring max age days.

Fixes #7320
This commit is contained in:
Mike McQuaid 2020-04-20 10:33:15 +01:00
parent dad4249774
commit 701c1811d5
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
5 changed files with 23 additions and 5 deletions

View File

@ -7,7 +7,6 @@ require "cask/cask_loader"
require "set"
CLEANUP_DEFAULT_DAYS = 30
CLEANUP_MAX_AGE_DAYS = 120
module CleanupRefinement
refine Pathname do
@ -132,7 +131,7 @@ module Homebrew
@args = args
@dry_run = dry_run
@scrub = scrub
@days = days || CLEANUP_MAX_AGE_DAYS
@days = days || Homebrew::EnvConfig.cleanup_max_age_days.to_i
@cache = cache
@cleaned_up_paths = Set.new
end

View File

@ -8,12 +8,14 @@ module Homebrew
def cleanup_args
Homebrew::CLI::Parser.new do
days = Homebrew::EnvConfig::ENVS[:HOMEBREW_CLEANUP_MAX_AGE_DAYS][:default]
usage_banner <<~EOS
`cleanup` [<options>] [<formula>|<cask>]
Remove stale lock files and outdated downloads for all formulae and casks,
and remove old versions of installed formulae. If arguments are specified,
only do this for the given formulae and casks.
only do this for the given formulae and casks. Removes all downloads more than
#{days} days old. This can be adjusted with `HOMEBREW_CLEANUP_MAX_AGE_DAYS`.
EOS
flag "--prune=",
description: "Remove all cache files older than specified <days>."

View File

@ -50,6 +50,10 @@ module Homebrew
"Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`.",
default: HOMEBREW_DEFAULT_CACHE,
},
HOMEBREW_CLEANUP_MAX_AGE_DAYS: {
description: "Cleanup all cached files older than this many days.",
default: 120,
},
HOMEBREW_COLOR: {
description: "If set, force colour output on non-TTY outputs.",
boolean: true,

View File

@ -60,7 +60,8 @@ Control Homebrew's anonymous aggregate user behaviour analytics. Read more at
Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks.
this for the given formulae and casks. Removes all downloads more than 120 days
old. This can be adjusted with `HOMEBREW_CLEANUP_MAX_AGE_DAYS`.
* `--prune`:
Remove all cache files older than specified *`days`*.
@ -1223,6 +1224,11 @@ Note that environment variables must have a value set to be detected. For exampl
*Default:* macOS: `$HOME/Library/Caches/Homebrew`, Linux: `$XDG_CACHE_HOME/Homebrew` or `$HOME/.cache/Homebrew`.
* `HOMEBREW_CLEANUP_MAX_AGE_DAYS`:
Cleanup all cached files older than this many days.
*Default:* `120`.
* `HOMEBREW_COLOR`:
If set, force colour output on non-TTY outputs.

View File

@ -54,7 +54,7 @@ Control Homebrew\'s anonymous aggregate user behaviour analytics\. Read more at
Regenerate the UUID used for Homebrew\'s analytics\.
.
.SS "\fBcleanup\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]"
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\.
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\. Removes all downloads more than 120 days old\. This can be adjusted with \fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR\.
.
.TP
\fB\-\-prune\fR
@ -1560,6 +1560,13 @@ Use the specified directory as the download cache\.
\fIDefault:\fR macOS: \fB$HOME/Library/Caches/Homebrew\fR, Linux: \fB$XDG_CACHE_HOME/Homebrew\fR or \fB$HOME/\.cache/Homebrew\fR\.
.
.TP
\fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR
Cleanup all cached files older than this many days\.
.
.IP
\fIDefault:\fR \fB120\fR\.
.
.TP
\fBHOMEBREW_COLOR\fR
If set, force colour output on non\-TTY outputs\.
.