about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-14T13·28+0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-16T18·56+0200
commitc5e4404580164d3edd043e79cf72bac5bdaecb42 (patch)
tree746ac321e286e5f7495cb922690437e213a201c0 /src/libstore
parentdffc3fe43bd3cbf95945065ee7822727b9fcea90 (diff)
nix copy: Revive progress bar
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/legacy-ssh-store.cc1
-rw-r--r--src/libstore/store-api.cc26
2 files changed, 25 insertions, 2 deletions
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index 65fe575d2536..855a7c99aed6 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -135,7 +135,6 @@ struct LegacySSHStore : public Store
 
         if (readInt(conn->from) != 1)
             throw Error("failed to add path '%s' to remote host '%s', info.path, host");
-
     }
 
     void narFromPath(const Path & path, Sink & sink) override
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();
         });
 }