aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/optimise-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-16 17:32:18 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-16 20:56:03 +0200
commitb4ed97e3a3116909fcaa79f5ce84487ed3838112 (patch)
treed8f1a29dc7a8049cfaa301ee2a04795afbf6c712 /src/libstore/optimise-store.cc
parent23b8b7e096d3a2a784387a09f68115706b1e9552 (diff)
nix optimise-store: Show how much space has been freed
Diffstat (limited to 'src/libstore/optimise-store.cc')
-rw-r--r--src/libstore/optimise-store.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index 5093305a1..f1325ba5a 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);
}