diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index ca63ef593..3524c8b1e 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -2470,10 +2470,10 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat if (nix::isDerivation(path.path.abs())) error("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() - ? i->second + auto dstPath = dstPathCached + ? *dstPathCached : [&]() { auto dstPath = fetchToStore( *store, @@ -2484,7 +2484,7 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat nullptr, repair); allowPath(dstPath); - srcToStore.insert_or_assign(path, dstPath); + srcToStore.lock()->try_emplace(path, dstPath); printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath)); return dstPath; }(); diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 06a687620..dac763268 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -306,7 +306,7 @@ private: /* Cache for calls to addToStore(); maps source paths to the store paths. */ - std::map srcToStore; + Sync> srcToStore; /** * A cache from path names to parse trees.