about summary refs log tree commit diff
path: root/src/libstore/optimise-store.cc
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-09-01T20·21+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-09-01T21·53+0200
commit8fb8c26b6d07d2aadf9cf85bda159c815996be89 (patch)
treec7aa813a7279895ddc2609cf26ab3faf36043f3a /src/libstore/optimise-store.cc
parent27a01d92c2be3e6c1be23f96d24c3d3358489a87 (diff)
Add an 'optimiseStore' remote procedure call.
Diffstat (limited to 'src/libstore/optimise-store.cc')
-rw-r--r--src/libstore/optimise-store.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index 208d9688ed98..dd18d66fa008 100644
--- a/src/libstore/optimise-store.cc
+++ b/src/libstore/optimise-store.cc
@@ -225,6 +225,22 @@ void LocalStore::optimiseStore(OptimiseStats & stats)
     }
 }
 
+static string showBytes(unsigned long long bytes)
+{
+    return (format("%.2f MiB") % (bytes / (1024.0 * 1024.0))).str();
+}
+
+void LocalStore::optimiseStore()
+{
+    OptimiseStats stats;
+
+    optimiseStore(stats);
+
+    printMsg(lvlError,
+        format("%1% freed by hard-linking %2% files")
+        % showBytes(stats.bytesFreed)
+        % stats.filesLinked);
+}
 
 void LocalStore::optimisePath(const Path & path)
 {