Skip to content

Commit

Permalink
cleandocstore: Support --all.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Nov 9, 2023
1 parent 311e5aa commit 215d0f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion batch/cleandocstore.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class CleanDocstore_Batch {
public $dry_run;
/** @var bool */
public $keep_temp;
/** @var int */
public $cutoff;
/** @var DocumentHashMatcher */
public $hash_matcher;
/** @var list<?DocumentFileTree> */
Expand All @@ -47,6 +49,7 @@ function __construct(Conf $conf, $docstores, $arg) {
$this->verbose = isset($arg["verbose"]);
$this->dry_run = isset($arg["dry-run"]);
$this->keep_temp = isset($arg["keep-temp"]);
$this->cutoff = isset($arg["all"]) ? Conf::$now + 86400 : Conf::$now - 86400;
$this->hash_matcher = new DocumentHashMatcher($arg["match"] ?? null);
}

Expand All @@ -64,7 +67,7 @@ function fparts_random_match() {
$fm = $ftree->random_match();
if ($fm->is_complete()
&& (($fm->treeid & 1) === 0
|| max($fm->atime(), $fm->mtime()) < Conf::$now - 86400)) {
|| max($fm->atime(), $fm->mtime()) < $this->cutoff)) {
++$n;
$fmatches[] = $fm;
} else {
Expand Down Expand Up @@ -223,6 +226,7 @@ static function make_args($argv) {
"dry-run,d Do not remove files",
"max-usage:,u: {f} =FRAC Clean until usage is below FRAC",
"min-usage:,U: {f} =FRAC Do not clean if usage is below FRAC",
"all Clean all files, including files recently modified",
"quiet,silent,q",
"keep-temp",
"docstore"
Expand Down

0 comments on commit 215d0f1

Please sign in to comment.