mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
Return map of StorePaths in copyPaths
This allows the caller to know what values were actually added to the store.
This commit is contained in:
parent
7e11cf3399
commit
0c9c1b8826
2 changed files with 20 additions and 9 deletions
|
@ -638,7 +638,7 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & storePaths,
|
std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & storePaths,
|
||||||
RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
|
RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
|
||||||
{
|
{
|
||||||
auto valid = dstStore->queryValidPaths(storePaths, substitute);
|
auto valid = dstStore->queryValidPaths(storePaths, substitute);
|
||||||
|
@ -647,7 +647,11 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
|
||||||
for (auto & path : storePaths)
|
for (auto & path : storePaths)
|
||||||
if (!valid.count(path)) missing.insert(srcStore->printStorePath(path));
|
if (!valid.count(path)) missing.insert(srcStore->printStorePath(path));
|
||||||
|
|
||||||
if (missing.empty()) return;
|
std::map<StorePath, StorePath> pathsMap;
|
||||||
|
for (auto & path : storePaths)
|
||||||
|
pathsMap.insert_or_assign(path, path);
|
||||||
|
|
||||||
|
if (missing.empty()) return pathsMap;
|
||||||
|
|
||||||
Activity act(*logger, lvlInfo, actCopyPaths, fmt("copying %d paths", missing.size()));
|
Activity act(*logger, lvlInfo, actCopyPaths, fmt("copying %d paths", missing.size()));
|
||||||
|
|
||||||
|
@ -677,6 +681,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
|
||||||
if (storePathForDst != storePath)
|
if (storePathForDst != storePath)
|
||||||
debug("replaced path '%s' to '%s' for substituter '%s'", srcStore->printStorePath(storePath), dstStore->printStorePath(storePathForDst), dstStore->getUri());
|
debug("replaced path '%s' to '%s' for substituter '%s'", srcStore->printStorePath(storePath), dstStore->printStorePath(storePathForDst), dstStore->getUri());
|
||||||
}
|
}
|
||||||
|
pathsMap.insert_or_assign(storePath, storePathForDst);
|
||||||
|
|
||||||
if (dstStore->isValidPath(storePathForDst)) {
|
if (dstStore->isValidPath(storePathForDst)) {
|
||||||
nrDone++;
|
nrDone++;
|
||||||
|
@ -704,6 +709,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
|
||||||
if (storePathForDst != storePath)
|
if (storePathForDst != storePath)
|
||||||
debug("replaced path '%s' to '%s' for substituter '%s'", srcStore->printStorePath(storePath), dstStore->printStorePath(storePathForDst), dstStore->getUri());
|
debug("replaced path '%s' to '%s' for substituter '%s'", srcStore->printStorePath(storePath), dstStore->printStorePath(storePathForDst), dstStore->getUri());
|
||||||
}
|
}
|
||||||
|
pathsMap.insert_or_assign(storePath, storePathForDst);
|
||||||
|
|
||||||
if (!dstStore->isValidPath(storePathForDst)) {
|
if (!dstStore->isValidPath(storePathForDst)) {
|
||||||
MaintainCount<decltype(nrRunning)> mc(nrRunning);
|
MaintainCount<decltype(nrRunning)> mc(nrRunning);
|
||||||
|
@ -723,6 +729,8 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
|
||||||
nrDone++;
|
nrDone++;
|
||||||
showProgress();
|
showProgress();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return pathsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -444,8 +444,9 @@ public:
|
||||||
virtual StorePathSet querySubstitutablePaths(const StorePathSet & paths) { return {}; };
|
virtual StorePathSet querySubstitutablePaths(const StorePathSet & paths) { return {}; };
|
||||||
|
|
||||||
/* Query substitute info (i.e. references, derivers and download
|
/* Query substitute info (i.e. references, derivers and download
|
||||||
sizes) of a set of paths. If a path does not have substitute
|
sizes) of a map of paths to their optional ca values. If a path
|
||||||
info, it's omitted from the resulting ‘infos’ map. */
|
does not have substitute info, it's omitted from the resulting
|
||||||
|
‘infos’ map. */
|
||||||
virtual void querySubstitutablePathInfos(const StorePathCAMap & paths,
|
virtual void querySubstitutablePathInfos(const StorePathCAMap & paths,
|
||||||
SubstitutablePathInfos & infos) { return; };
|
SubstitutablePathInfos & infos) { return; };
|
||||||
|
|
||||||
|
@ -743,11 +744,13 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
|
||||||
|
|
||||||
|
|
||||||
/* Copy store paths from one store to another. The paths may be copied
|
/* Copy store paths from one store to another. The paths may be copied
|
||||||
in parallel. They are copied in a topologically sorted order
|
in parallel. They are copied in a topologically sorted order (i.e.
|
||||||
(i.e. if A is a reference of B, then A is copied before B), but
|
if A is a reference of B, then A is copied before B), but the set
|
||||||
the set of store paths is not automatically closed; use
|
of store paths is not automatically closed; use copyClosure() for
|
||||||
copyClosure() for that. */
|
that. Returns a map of what each path was copied to the dstStore
|
||||||
void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & storePaths,
|
as. */
|
||||||
|
std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStore,
|
||||||
|
const StorePathSet & storePaths,
|
||||||
RepairFlag repair = NoRepair,
|
RepairFlag repair = NoRepair,
|
||||||
CheckSigsFlag checkSigs = CheckSigs,
|
CheckSigsFlag checkSigs = CheckSigs,
|
||||||
SubstituteFlag substitute = NoSubstitute);
|
SubstituteFlag substitute = NoSubstitute);
|
||||||
|
|
Loading…
Reference in a new issue