diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2016-10-07T17·15+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2016-10-07T17·15+0200 |
commit | 35db4f65a0f2ccbcaaef719e52b895fa78cad361 (patch) | |
tree | 49cd1bd79c53bc14502ea3fb11297549a0aa620c /src/libstore/store-api.cc | |
parent | 629ab8002218e9b526d947a9b7a2eccddc3f331c (diff) |
Add copyClosure utility function for Hydra
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 90e1747157d4..74014b47e513 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -414,6 +414,30 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore, } +void copyClosure(ref<Store> srcStore, ref<Store> dstStore, + const PathSet & storePaths, bool repair) +{ + PathSet closure; + for (auto & path : storePaths) + srcStore->computeFSClosure(path, closure); + + PathSet valid = dstStore->queryValidPaths(closure); + + if (valid.size() == closure.size()) return; + + Paths sorted = srcStore->topoSortPaths(closure); + + Paths missing; + for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) + if (!valid.count(*i)) missing.push_back(*i); + + printMsg(lvlDebug, format("copying %1% missing paths") % missing.size()); + + for (auto & i : missing) + copyStorePath(srcStore, dstStore, i, repair); +} + + ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven) { ValidPathInfo info; |