mirror of
https://github.com/NixOS/nix.git
synced 2025-11-22 10:19:36 +01:00
chore: format
This commit is contained in:
parent
f2587b713b
commit
d01aa17a82
3 changed files with 20 additions and 8 deletions
|
|
@ -145,7 +145,8 @@ void deleteGenerations(const Path & profile, const std::set<GenerationNumber> &
|
|||
* - olderThan is 2025-09-16, keepMin is 5, keepMax is 10 -
|
||||
* Will try to delete generations older than 2025-09-16.
|
||||
* If there are more than 10 generations to be kept, continues to delete old generations until there are 10.
|
||||
* If there are less than 5 generations to be kept, preserves the most recent of generations to be deleted until there are 5.
|
||||
* If there are less than 5 generations to be kept, preserves the most recent of generations to be deleted until there
|
||||
* are 5.
|
||||
*
|
||||
* @param profile The profile, specified by its name and location combined into a path, whose generations we want to
|
||||
* delete.
|
||||
|
|
@ -161,7 +162,12 @@ void deleteGenerations(const Path & profile, const std::set<GenerationNumber> &
|
|||
*
|
||||
* @param dryRun Log what would be deleted instead of actually doing so.
|
||||
*/
|
||||
void deleteGenerationsFilter(const Path & profile, std::optional<time_t> olderThan, std::optional<GenerationNumber> keepMin, std::optional<GenerationNumber> keepMax, bool dryRun);
|
||||
void deleteGenerationsFilter(
|
||||
const Path & profile,
|
||||
std::optional<time_t> olderThan,
|
||||
std::optional<GenerationNumber> keepMin,
|
||||
std::optional<GenerationNumber> keepMax,
|
||||
bool dryRun);
|
||||
|
||||
/**
|
||||
* Delete generations older than `max` passed the current generation.
|
||||
|
|
|
|||
|
|
@ -163,7 +163,12 @@ static inline void iterDropUntil(Generations & gens, auto && i, auto && cond)
|
|||
;
|
||||
}
|
||||
|
||||
void deleteGenerationsFilter(const Path & profile, std::optional<time_t> olderThan, std::optional<GenerationNumber> keepMin, std::optional<GenerationNumber> keepMax, bool dryRun)
|
||||
void deleteGenerationsFilter(
|
||||
const Path & profile,
|
||||
std::optional<time_t> olderThan,
|
||||
std::optional<GenerationNumber> keepMin,
|
||||
std::optional<GenerationNumber> keepMax,
|
||||
bool dryRun)
|
||||
{
|
||||
if (keepMin.has_value() && keepMax.has_value() && *keepMin > *keepMax)
|
||||
throw Error("--keep-min cannot be greater than --keep-max");
|
||||
|
|
|
|||
|
|
@ -82,12 +82,13 @@ static int main_nix_collect_garbage(int argc, char ** argv)
|
|||
removeOld = true;
|
||||
deleteOlderThan = std::optional<time_t>{parseOlderThanTimeSpec(getArg(*arg, arg, end))};
|
||||
} else if (*arg == "--keep-min")
|
||||
keepMin = std::optional<GenerationNumber> { std::max(getIntArg<GenerationNumber>(*arg, arg, end, false), (GenerationNumber) 1) };
|
||||
keepMin = std::optional<GenerationNumber>{
|
||||
std::max(getIntArg<GenerationNumber>(*arg, arg, end, false), (GenerationNumber) 1)};
|
||||
else if (*arg == "--keep-max") {
|
||||
removeOld = true;
|
||||
keepMax = std::optional<GenerationNumber> { std::max(getIntArg<GenerationNumber>(*arg, arg, end, false), (GenerationNumber) 1) };
|
||||
}
|
||||
else if (*arg == "--dry-run")
|
||||
keepMax = std::optional<GenerationNumber>{
|
||||
std::max(getIntArg<GenerationNumber>(*arg, arg, end, false), (GenerationNumber) 1)};
|
||||
} else if (*arg == "--dry-run")
|
||||
dryRun = true;
|
||||
else if (*arg == "--max-freed")
|
||||
options.maxFreed = std::max(getIntArg<int64_t>(*arg, arg, end, true), (int64_t) 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue