about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-16T15·32+0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-16T18·56+0200
commitb4ed97e3a3116909fcaa79f5ce84487ed3838112 (patch)
treed8f1a29dc7a8049cfaa301ee2a04795afbf6c712 /src/libstore
parent23b8b7e096d3a2a784387a09f68115706b1e9552 (diff)
nix optimise-store: Show how much space has been freed
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc2
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/optimise-store.cc14
3 files changed, 11 insertions, 7 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 1a1fc1dee54d..fc039a8e52b5 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -3257,7 +3257,7 @@ void DerivationGoal::flushLine()
         logTail.push_back(currentLogLine);
         if (logTail.size() > settings.logLines) logTail.pop_front();
     }
-    act->progress(currentLogLine);
+    act->result(resBuildLogLine, currentLogLine);
     currentLogLine = "";
     currentLogLinePos = 0;
 }
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 551c6b506fb1..2af1bfbb3892 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -251,7 +251,7 @@ private:
 
     InodeHash loadInodeHash();
     Strings readDirectoryIgnoringInodes(const Path & path, const InodeHash & inodeHash);
-    void optimisePath_(OptimiseStats & stats, const Path & path, InodeHash & inodeHash);
+    void optimisePath_(Activity * act, OptimiseStats & stats, const Path & path, InodeHash & inodeHash);
 
     // Internal versions that are not wrapped in retry_sqlite.
     bool isValidPath_(State & state, const Path & path);
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index 5093305a13e3..f1325ba5a1ce 100644
--- a/src/libstore/optimise-store.cc
+++ b/src/libstore/optimise-store.cc
@@ -89,7 +89,8 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path & path, const InodeHa
 }
 
 
-void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHash & inodeHash)
+void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
+    const Path & path, InodeHash & inodeHash)
 {
     checkInterrupt();
 
@@ -114,7 +115,7 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
     if (S_ISDIR(st.st_mode)) {
         Strings names = readDirectoryIgnoringInodes(path, inodeHash);
         for (auto & i : names)
-            optimisePath_(stats, path + "/" + i, inodeHash);
+            optimisePath_(act, stats, path + "/" + i, inodeHash);
         return;
     }
 
@@ -244,6 +245,9 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
     stats.filesLinked++;
     stats.bytesFreed += st.st_size;
     stats.blocksFreed += st.st_blocks;
+
+    if (act)
+        act->result(resFileLinked, st.st_size, st.st_blocks);
 }
 
 
@@ -263,7 +267,7 @@ void LocalStore::optimiseStore(OptimiseStats & stats)
         if (!isValidPath(i)) continue; /* path was GC'ed, probably */
         {
             Activity act(*logger, actUnknown, fmt("optimising path '%s'", i));
-            optimisePath_(stats, realStoreDir + "/" + baseNameOf(i), inodeHash);
+            optimisePath_(&act, stats, realStoreDir + "/" + baseNameOf(i), inodeHash);
         }
         done++;
         act.progress(done, paths.size());
@@ -281,7 +285,7 @@ void LocalStore::optimiseStore()
 
     optimiseStore(stats);
 
-    printError(
+    printInfo(
         format("%1% freed by hard-linking %2% files")
         % showBytes(stats.bytesFreed)
         % stats.filesLinked);
@@ -292,7 +296,7 @@ void LocalStore::optimisePath(const Path & path)
     OptimiseStats stats;
     InodeHash inodeHash;
 
-    if (settings.autoOptimiseStore) optimisePath_(stats, path, inodeHash);
+    if (settings.autoOptimiseStore) optimisePath_(nullptr, stats, path, inodeHash);
 }