about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-08-11T20·26+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-08-11T20·26+0000
commit4250b641d8e8edc4cb7def9bc463c7e4ff82e144 (patch)
treee90895b2154163a1b0be61616220e4215cf6159c /src/libstore
parent92f7dfa5b73e44f7584eaed726927450a29a48b8 (diff)
* `nix-store --gc --print-dead': print the total size of the store
  objects that would be freed.

Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/gc.cc9
1 files changed, 9 insertions, 0 deletions
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__