about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-12-15T21·11+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-12-15T21·11+0000
commit530b27df1e71852580d8b0d474543aeffe65618f (patch)
tree166f79c170b19ad82ca6bf9a3c77b96325b72aa1 /src/libstore
parent5144f750c471cdb629750e96ddc913fb01fb9eef (diff)
* `nix-store --gc' prints out the number of bytes freed on stdout
  (even when it is interrupted by a signal).

Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/gc.cc8
-rw-r--r--src/libstore/gc.hh3
-rw-r--r--src/libstore/store.cc5
-rw-r--r--src/libstore/store.hh2
4 files changed, 12 insertions, 6 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index bdaf2946ca58..cb808b6d1b68 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -303,9 +303,11 @@ static Paths topoSort(const PathSet & paths)
 }
 
 
-void collectGarbage(GCAction action, PathSet & result)
+void collectGarbage(GCAction action, PathSet & result,
+    unsigned long long & bytesFreed)
 {
     result.clear();
+    bytesFreed = 0;
 
     bool gcKeepOutputs =
         queryBoolSetting("gc-keep-outputs", false);
@@ -452,7 +454,9 @@ void collectGarbage(GCAction action, PathSet & result)
             printMsg(lvlInfo, format("deleting `%1%'") % *i);
             
             /* Okay, it's safe to delete. */
-            deleteFromStore(*i);
+            unsigned long long freed;
+            deleteFromStore(*i, freed);
+            bytesFreed += freed;
 
             if (fdLock != -1)
                 /* Write token to stale (deleted) lock file. */
diff --git a/src/libstore/gc.hh b/src/libstore/gc.hh
index b6a367c4b330..eb1858729037 100644
--- a/src/libstore/gc.hh
+++ b/src/libstore/gc.hh
@@ -19,7 +19,8 @@ typedef enum {
    closure of) the roots.  If `action' is `gcReturnDead', return the
    set of paths not reachable from the roots.  If `action' is
    `gcDeleteDead', actually delete the latter set. */
-void collectGarbage(GCAction action, PathSet & result);
+void collectGarbage(GCAction action, PathSet & result,
+    unsigned long long & bytesFreed);
 
 /* Register a temporary GC root.  This root will automatically
    disappear when this process exits.  WARNING: this function should
diff --git a/src/libstore/store.cc b/src/libstore/store.cc
index 281ccc4bf147..dc3625a1d5da 100644
--- a/src/libstore/store.cc
+++ b/src/libstore/store.cc
@@ -746,8 +746,9 @@ Path addTextToStore(const string & suffix, const string & s,
 }
 
 
-void deleteFromStore(const Path & _path)
+void deleteFromStore(const Path & _path, unsigned long long & bytesFreed)
 {
+    bytesFreed = 0;
     Path path(canonPath(_path));
 
     assertStorePath(path);
@@ -763,7 +764,7 @@ void deleteFromStore(const Path & _path)
     }
     txn.commit();
 
-    deletePath(path);
+    deletePath(path, bytesFreed);
 }
 
 
diff --git a/src/libstore/store.hh b/src/libstore/store.hh
index 0f35ff0c626c..2d8018d5fabc 100644
--- a/src/libstore/store.hh
+++ b/src/libstore/store.hh
@@ -155,7 +155,7 @@ Path addTextToStore(const string & suffix, const string & s,
     const PathSet & references);
 
 /* Delete a value from the nixStore directory. */
-void deleteFromStore(const Path & path);
+void deleteFromStore(const Path & path, unsigned long long & bytesFreed);
 
 void verifyStore(bool checkContents);