diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-14T13·28+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-16T18·56+0200 |
commit | c5e4404580164d3edd043e79cf72bac5bdaecb42 (patch) | |
tree | 746ac321e286e5f7495cb922690437e213a201c0 /src/libstore/store-api.cc | |
parent | dffc3fe43bd3cbf95945065ee7822727b9fcea90 (diff) |
nix copy: Revive progress bar
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index dd87a046e380..88f27e806dce 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -565,8 +565,12 @@ void Store::buildPaths(const PathSet & paths, BuildMode buildMode) void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, const Path & storePath, RepairFlag repair, CheckSigsFlag checkSigs) { + Activity act(actCopyPath, fmt("copying path '%s'", storePath)); + auto info = srcStore->queryPathInfo(storePath); + //act->progress(0, info->size()); + StringSink sink; srcStore->narFromPath({storePath}, sink); @@ -600,13 +604,28 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const PathSet & storePa for (auto & path : storePaths) if (!valid.count(path)) missing.insert(path); + Activity act; + + logger->event(evCopyStarted, act); + + std::atomic<size_t> nrCopied{0}; + std::atomic<size_t> nrDone{storePaths.size() - missing.size()}; + + auto showProgress = [&]() { + logger->event(evCopyProgress, act, storePaths.size(), nrCopied, nrDone); + }; + ThreadPool pool; processGraph<Path>(pool, PathSet(missing.begin(), missing.end()), [&](const Path & storePath) { - if (dstStore->isValidPath(storePath)) return PathSet(); + if (dstStore->isValidPath(storePath)) { + nrDone++; + showProgress(); + return PathSet(); + } return srcStore->queryPathInfo(storePath)->references; }, @@ -616,7 +635,12 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const PathSet & storePa if (!dstStore->isValidPath(storePath)) { printInfo("copying '%s'...", storePath); copyStorePath(srcStore, dstStore, storePath, repair, checkSigs); + nrCopied++; } + + nrDone++; + + showProgress(); }); } |