From b4ed97e3a3116909fcaa79f5ce84487ed3838112 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 16 Aug 2017 17:32:18 +0200 Subject: nix optimise-store: Show how much space has been freed --- src/libstore/build.cc | 2 +- src/libstore/local-store.hh | 2 +- src/libstore/optimise-store.cc | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/libstore') 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); } -- cgit 1.4.1