mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Merge pull request #10853 from DeterminateSystems/thread-safe-srcToStore
Make EvalState::srcToStore thread-safe
This commit is contained in:
commit
e1b3716d50
2 changed files with 5 additions and 5 deletions
|
@ -2470,10 +2470,10 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
|
||||||
if (nix::isDerivation(path.path.abs()))
|
if (nix::isDerivation(path.path.abs()))
|
||||||
error<EvalError>("file names are not allowed to end in '%1%'", drvExtension).debugThrow();
|
error<EvalError>("file names are not allowed to end in '%1%'", drvExtension).debugThrow();
|
||||||
|
|
||||||
auto i = srcToStore.find(path);
|
auto dstPathCached = get(*srcToStore.lock(), path);
|
||||||
|
|
||||||
auto dstPath = i != srcToStore.end()
|
auto dstPath = dstPathCached
|
||||||
? i->second
|
? *dstPathCached
|
||||||
: [&]() {
|
: [&]() {
|
||||||
auto dstPath = fetchToStore(
|
auto dstPath = fetchToStore(
|
||||||
*store,
|
*store,
|
||||||
|
@ -2484,7 +2484,7 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
|
||||||
nullptr,
|
nullptr,
|
||||||
repair);
|
repair);
|
||||||
allowPath(dstPath);
|
allowPath(dstPath);
|
||||||
srcToStore.insert_or_assign(path, dstPath);
|
srcToStore.lock()->try_emplace(path, dstPath);
|
||||||
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
||||||
return dstPath;
|
return dstPath;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -306,7 +306,7 @@ private:
|
||||||
|
|
||||||
/* Cache for calls to addToStore(); maps source paths to the store
|
/* Cache for calls to addToStore(); maps source paths to the store
|
||||||
paths. */
|
paths. */
|
||||||
std::map<SourcePath, StorePath> srcToStore;
|
Sync<std::map<SourcePath, StorePath>> srcToStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cache from path names to parse trees.
|
* A cache from path names to parse trees.
|
||||||
|
|
Loading…
Reference in a new issue