summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-11-22 11:33:29 +0100
committerLudovic Courtès <ludo@gnu.org>2019-11-22 12:17:43 +0100
commit732c96f182386d1be00ebf47d332d8c81b878dcf (patch)
tree71c2c07d525d9e00f11fe0b6956d1423183ff092 /nix
parent4f5234be0378368e6af25925db46612838d25e58 (diff)
downloadpatches-732c96f182386d1be00ebf47d332d8c81b878dcf.tar
patches-732c96f182386d1be00ebf47d332d8c81b878dcf.tar.gz
daemon: GC displays how much it has collected.
* nix/libstore/gc.cc (LocalStore::deletePathRecursive): Display the percentage reached relative to 'maxFreed', or the total amount of data deleted when 'maxFreed' is ULLONG_MAX.
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/gc.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index fe152da015..7976ff7d76 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -11,6 +11,7 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
+#include <climits>
namespace nix {
@@ -417,7 +418,15 @@ void LocalStore::deletePathRecursive(GCState & state, const Path & path)
throw SysError(format("getting status of %1%") % path);
}
- printMsg(lvlInfo, format("deleting `%1%'") % path);
+ if (state.options.maxFreed != ULLONG_MAX) {
+ double fraction = state.results.bytesFreed + size
+ / state.options.maxFreed;
+ unsigned int percentage = (fraction > 1. ? 1. : fraction) * 100.;
+ printMsg(lvlInfo, format("[%1%%%] deleting '%2%'") % percentage % path);
+ } else {
+ size_t total = (state.results.bytesFreed + size) / (1024 * 1024);
+ printMsg(lvlInfo, format("[%1% MiB] deleting '%2%'") % total % path);
+ }
state.results.paths.insert(path);