about summary refs log tree commit diff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-05-03T12·45+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-05-04T09·01+0200
commitdfebfc835f7b8156a559314bcd1ecff739c14fd1 (patch)
tree94843083056eabd89f3892e71f4cc6173b1189d8 /src/libstore/store-api.cc
parent80f739b571771b56b9930fbf1ca3e3a4128b46cb (diff)
Add a copyStorePath() utility function
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 463e132e0299..b03e4080afc2 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -357,6 +357,19 @@ const Store::Stats & Store::getStats()
 }
 
 
+void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
+    const Path & storePath)
+{
+    auto info = srcStore->queryPathInfo(storePath);
+
+    StringSink sink;
+    srcStore->exportPaths({storePath}, false, sink);
+
+    StringSource source(*sink.s);
+    dstStore->importPaths(false, source, 0);
+}
+
+
 ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven)
 {
     ValidPathInfo info;