From 4250b641d8e8edc4cb7def9bc463c7e4ff82e144 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 11 Aug 2006 20:26:49 +0000 Subject: * `nix-store --gc --print-dead': print the total size of the store objects that would be freed. --- src/libstore/gc.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libstore/gc.cc') diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 01d85d4d525e..37fde29ca035 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -515,6 +515,15 @@ void collectGarbage(GCAction action, const PathSet & pathsToDelete, debug(format("dead path `%1%'") % *i); result.insert(*i); + /* If just returning the set of dead paths, we also return the + space that would be freed if we deleted them. */ + if (action == gcReturnDead) { + struct stat st; + if (lstat(i->c_str(), &st) == -1) + st.st_size = 0; + bytesFreed += st.st_size; + } + if (action == gcDeleteDead || action == gcDeleteSpecific) { #ifndef __CYGWIN__ -- cgit 1.4.1