diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2017-01-19T17·21+0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-19T17·21+0100 |
commit | 8af062f372ae5db6a90700641f15d98505b4a839 (patch) | |
tree | 1c4f61be3cca82b3a03255557d9e5f3d87107018 /src/libstore/store-api.cc | |
parent | 21948deed99a3295e4d5666e027a6ca42dc00b40 (diff) | |
parent | 28db29786277ce6790ffb1567f9e679c62737b96 (diff) |
Merge pull request #981 from shlevy/build-remote-c++
build-remote: Implement in C++
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 33 |
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(); +} + + } |