1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 07:31:15 +02:00

Memoise checkSourcePath()

This prevents hydra-eval-jobs from statting the same files over and
over again.
This commit is contained in:
Eelco Dolstra 2018-05-22 13:02:14 +02:00
parent 9064dd2f4d
commit 9fd7cf98db
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 11 additions and 1 deletions

View file

@ -352,6 +352,10 @@ Path EvalState::checkSourcePath(const Path & path_)
{
if (!allowedPaths) return path_;
auto i = resolvedPaths.find(path_);
if (i != resolvedPaths.end())
return i->second;
bool found = false;
for (auto & i : *allowedPaths) {
@ -369,8 +373,10 @@ Path EvalState::checkSourcePath(const Path & path_)
Path path = canonPath(path_, true);
for (auto & i : *allowedPaths) {
if (isDirOrInDir(path, i))
if (isDirOrInDir(path, i)) {
resolvedPaths[path_] = path;
return path;
}
}
throw RestrictedPathError("access to path '%1%' is forbidden in restricted mode", path);