From 0e0dcf2c7ec054f1b30629e275f53f56039b8257 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 14 Aug 2017 22:12:36 +0200 Subject: Progress indicator: Unify "copying" and "substituting" They're the same thing after all. Example: $ nix build --store local?root=/tmp/nix nixpkgs.firefox-unwrapped [0/1 built, 49/98 copied, 16.3/92.8 MiB DL, 55.8/309.2 MiB copied] downloading 'https://cache.nixos.org/nar/0pl9li1jigcj2dany47hpmn0r3r48wc4nz48v5mqhh426lgz3bz6.nar.xz' --- src/libstore/store-api.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/libstore/store-api.cc') diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 2b99a07e2af3..1e11e54eba7c 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -621,16 +621,13 @@ void copyPaths(ref srcStore, ref dstStore, const PathSet & storePa for (auto & path : storePaths) if (!valid.count(path)) missing.insert(path); - Activity act(actUnknown); + Activity act(actCopyPaths, fmt("copying %d paths", missing.size())); - logger->event(evCopyStarted, act); - - std::atomic nrCopied{0}; - std::atomic nrDone{storePaths.size() - missing.size()}; + std::atomic nrDone{0}; std::atomic bytesExpected{0}; auto showProgress = [&]() { - logger->event(evCopyProgress, act, storePaths.size(), nrCopied, nrDone); + act.progress(nrDone, missing.size()); }; ThreadPool pool; @@ -659,11 +656,9 @@ void copyPaths(ref srcStore, ref dstStore, const PathSet & storePa if (!dstStore->isValidPath(storePath)) { printInfo("copying '%s'...", storePath); copyStorePath(srcStore, dstStore, storePath, repair, checkSigs); - nrCopied++; } nrDone++; - showProgress(); }); } -- cgit 1.4.1