diff options
author | Niels Egberts <git@nielsegberts.nl> | 2021-07-11 11:15:06 +0100 |
---|---|---|
committer | Niels Egberts <git@nielsegberts.nl> | 2021-07-11 11:24:43 +0100 |
commit | 2cf14db857fa4be3b60b6497bc4458d5b589154f (patch) | |
tree | 42e97345b7986c40bcaf7220836dc753b0070d80 /src/libstore/profiles.cc | |
parent | 86fb01c4bee0c4f451504c0f6fd2066d2adc8fc2 (diff) |
Throw on unexpected input for --delete-older-than
'--delete-older-than 10' deletes the generations older than a single day, and '--delete-older-than 12m' deletes all generations older than 12 days.
This changes makes it throw on those invalid inputs, and gives an example of a valid input.
Diffstat (limited to 'src/libstore/profiles.cc')
-rw-r--r-- | src/libstore/profiles.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc index 5d1723886..75db8f9df 100644 --- a/src/libstore/profiles.cc +++ b/src/libstore/profiles.cc @@ -211,6 +211,9 @@ void deleteGenerationsOlderThan(const Path & profile, time_t t, bool dryRun) void deleteGenerationsOlderThan(const Path & profile, const string & timeSpec, bool dryRun) { + if (timeSpec.empty() || timeSpec[timeSpec.size() - 1] != 'd') + throw Error("invalid number of days specifier '%1%', expected something like '14d'", timeSpec); + time_t curTime = time(0); string strDays = string(timeSpec, 0, timeSpec.size() - 1); auto days = string2Int<int>(strDays); |