about summary refs log tree commit diff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/gc.cc')
-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__