From 530b27df1e71852580d8b0d474543aeffe65618f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 15 Dec 2005 21:11:39 +0000 Subject: * `nix-store --gc' prints out the number of bytes freed on stdout (even when it is interrupted by a signal). --- src/nix-store/main.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/nix-store/main.cc') diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc index d1a96aa3a..8bb1b1254 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) -- cgit v1.2.3