diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-12-15 21:11:39 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-12-15 21:11:39 +0000 |
commit | 530b27df1e71852580d8b0d474543aeffe65618f (patch) | |
tree | 166f79c170b19ad82ca6bf9a3c77b96325b72aa1 /src/nix-store | |
parent | 5144f750c471cdb629750e96ddc913fb01fb9eef (diff) | |
download | guix-530b27df1e71852580d8b0d474543aeffe65618f.tar.gz |
* `nix-store --gc' prints out the number of bytes freed on stdout
(even when it is interrupted by a signal).
Diffstat (limited to 'src/nix-store')
-rw-r--r-- | src/nix-store/main.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index d1a96aa3a9..8bb1b12543 100644 --- a/src/nix-store/main.cc +++ b/src/nix-store/main.cc @@ -489,6 +489,20 @@ static void opCheckValidity(Strings opFlags, Strings opArgs) } +struct PrintFreed +{ + bool show; + unsigned long long bytesFreed; + PrintFreed(bool _show) : bytesFreed(0), show(_show) { } + ~PrintFreed() + { + if (show) + cout << format("%d bytes freed (%.2f MiB)\n") + % bytesFreed % (bytesFreed / (1024.0 * 1024.0)); + } +}; + + static void opGC(Strings opFlags, Strings opArgs) { GCAction action = gcDeleteDead; @@ -503,7 +517,8 @@ static void opGC(Strings opFlags, Strings opArgs) else throw UsageError(format("bad sub-operation `%1%' in GC") % *i); PathSet result; - collectGarbage(action, result); + PrintFreed freed(action == gcDeleteDead); + collectGarbage(action, result, freed.bytesFreed); if (action != gcDeleteDead) { for (PathSet::iterator i = result.begin(); i != result.end(); ++i) |