about summary refs log tree commit diff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2016-07-18T22·50-0400
committerShea Levy <shea@shealevy.com>2016-11-10T16·09-0500
commit167d12b02cc8cadfaf7c28959532030d65687a8f (patch)
tree37907cb4370b395da98c592ae1b73070acd8ed2b /src/libstore/store-api.cc
parent2af5d35fdc1171a9bdab7e2fc005673d76417c06 (diff)
build-remote: Implement in C++
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 37a2d45fefe0..8fdd62771552 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -3,6 +3,7 @@
 #include "store-api.hh"
 #include "util.hh"
 #include "nar-info-disk-cache.hh"
+#include "thread-pool.hh"
 
 #include <future>
 
@@ -698,4 +699,36 @@ std::list<ref<Store>> getDefaultSubstituters()
 }
 
 
+void copyPaths(ref<Store> from, ref<Store> to, const Paths & storePaths)
+{
+    std::string copiedLabel = "copied";
+
+    logger->setExpected(copiedLabel, storePaths.size());
+
+    ThreadPool pool;
+
+    processGraph<Path>(pool,
+        PathSet(storePaths.begin(), storePaths.end()),
+
+        [&](const Path & storePath) {
+            return from->queryPathInfo(storePath)->references;
+        },
+
+        [&](const Path & storePath) {
+            checkInterrupt();
+
+            if (!to->isValidPath(storePath)) {
+                Activity act(*logger, lvlInfo, format("copying ‘%s’...") % storePath);
+
+                copyStorePath(from, to, storePath);
+
+                logger->incProgress(copiedLabel);
+            } else
+                logger->incExpected(copiedLabel, -1);
+        });
+
+    pool.process();
+}
+
+
 }