nix optimise-store: Add

This replaces "nix-store --optimise". Main difference is that it has a
progress indicator.
This commit is contained in:
Eelco Dolstra 2017-08-16 17:00:24 +02:00
parent 40bffe0a43
commit 23b8b7e096
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 60 additions and 6 deletions

View file

@ -249,14 +249,24 @@ void LocalStore::optimisePath_(OptimiseStats & stats, const Path & path, InodeHa
void LocalStore::optimiseStore(OptimiseStats & stats)
{
Activity act(*logger, actOptimiseStore);
PathSet paths = queryAllValidPaths();
InodeHash inodeHash = loadInodeHash();
act.progress(0, paths.size());
uint64_t done = 0;
for (auto & i : paths) {
addTempRoot(i);
if (!isValidPath(i)) continue; /* path was GC'ed, probably */
//Activity act(*logger, lvlChatty, format("hashing files in '%1%'") % i);
optimisePath_(stats, realStoreDir + "/" + baseNameOf(i), inodeHash);
{
Activity act(*logger, actUnknown, fmt("optimising path '%s'", i));
optimisePath_(stats, realStoreDir + "/" + baseNameOf(i), inodeHash);
}
done++;
act.progress(done, paths.size());
}
}