about summary refs log tree commit diff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-02T02·43-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-02T02·43-0400
commit6763084ae53fc0228d50ab94bbbced89c1b14f1c (patch)
tree07d162ac68a26df478b406b634a6668fe0af3c3e /src/libstore/gc.cc
parent01d56c1eeca497de247413a64a544605c53d9d41 (diff)
Count bytes freed deleting unused links
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r--src/libstore/gc.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index a1bb4051cd..255dc3aa09 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -575,7 +575,7 @@ bool LocalStore::tryToDelete(GCState & state, const Path & path)
    safely deleted.  FIXME: race condition with optimisePath(): we
    might see a link count of 1 just before optimisePath() increases
    the link count. */
-void LocalStore::removeUnusedLinks()
+void LocalStore::removeUnusedLinks(const GCState & state)
 {
     AutoCloseDir dir = opendir(linksDir.c_str());
     if (!dir) throw SysError(format("opening directory `%1%'") % linksDir);
@@ -604,6 +604,8 @@ void LocalStore::removeUnusedLinks()
 
         if (unlink(path.c_str()) == -1)
             throw SysError(format("deleting `%1%'") % path);
+
+        state.results.bytesFreed += st.st_blocks * 512;
     }
 
     struct stat st;
@@ -732,7 +734,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results)
 
     /* Clean up the links directory. */
     printMsg(lvlError, format("deleting unused links..."));
-    removeUnusedLinks();
+    removeUnusedLinks(state);
 }