1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 05:01:48 +02:00

* nix-store --optimise: flag "--dry-run" to just query what the disk

savings would be.
This commit is contained in:
Eelco Dolstra 2007-10-10 13:43:04 +00:00
parent a8629de827
commit 315183f194
2 changed files with 24 additions and 16 deletions

View file

@ -640,16 +640,19 @@ static void opOptimise(Strings opFlags, Strings opArgs)
if (!opArgs.empty())
throw UsageError("no arguments expected");
bool dryRun = false;
for (Strings::iterator i = opFlags.begin();
i != opFlags.end(); ++i)
throw UsageError(format("unknown flag `%1%'") % *i);
if (*i == "--dry-run") dryRun = true;
else throw UsageError(format("unknown flag `%1%'") % *i);
LocalStore * store2(dynamic_cast<LocalStore *>(store.get()));
if (!store2) throw Error("you don't have sufficient rights to use --optimise");
OptimiseStats stats;
try {
store2->optimiseStore(true, stats);
store2->optimiseStore(dryRun, stats);
} catch (...) {
showOptimiseStats(stats);
throw;