mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Add a copyStorePath() utility function
This commit is contained in:
parent
80f739b571
commit
dfebfc835f
5 changed files with 27 additions and 10 deletions
|
@ -3222,11 +3222,7 @@ void SubstitutionGoal::tryToRun()
|
|||
/* Wake up the worker loop when we're done. */
|
||||
Finally updateStats([this]() { outPipe.writeSide.close(); });
|
||||
|
||||
StringSink sink;
|
||||
sub->exportPaths({storePath}, false, sink);
|
||||
|
||||
StringSource source(*sink.s);
|
||||
worker.store.importPaths(false, source, 0);
|
||||
copyStorePath(ref<Store>(sub), ref<Store>(worker.store.shared_from_this()), storePath);
|
||||
|
||||
promise.set_value();
|
||||
} catch (...) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -502,6 +502,11 @@ Path computeStorePathForText(const string & name, const string & s,
|
|||
const PathSet & references);
|
||||
|
||||
|
||||
/* Copy a path from one store to another. */
|
||||
void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
|
||||
const Path & storePath);
|
||||
|
||||
|
||||
/* Remove the temporary roots file for this process. Any temporary
|
||||
root becomes garbage after this point unless it has been registered
|
||||
as a (permanent) root. */
|
||||
|
|
|
@ -28,6 +28,13 @@ public:
|
|||
throw std::invalid_argument("null pointer cast to ref");
|
||||
}
|
||||
|
||||
explicit ref<T>(T * p)
|
||||
: p(p)
|
||||
{
|
||||
if (!p)
|
||||
throw std::invalid_argument("null pointer cast to ref");
|
||||
}
|
||||
|
||||
T* operator ->() const
|
||||
{
|
||||
return &*p;
|
||||
|
|
|
@ -65,11 +65,7 @@ struct CmdCopy : StorePathsCommand
|
|||
if (!dstStore->isValidPath(storePath)) {
|
||||
Activity act(*logger, lvlInfo, format("copying ‘%s’...") % storePath);
|
||||
|
||||
StringSink sink;
|
||||
srcStore->exportPaths({storePath}, false, sink);
|
||||
|
||||
StringSource source(*sink.s);
|
||||
dstStore->importPaths(false, source, 0);
|
||||
copyStorePath(srcStore, dstStore, storePath);
|
||||
|
||||
logger->incProgress(copiedLabel);
|
||||
} else
|
||||
|
|
Loading…
Reference in a new issue