libutil/union-source-accessor: Barf on non-existent directories
Previously builtins.readDir would return an empty attribute set instead of barfing on non-existent paths. This is a regression from 2.32 for impure eval.
This commit is contained in:
@@ -35,14 +35,18 @@ struct UnionSourceAccessor : SourceAccessor
|
||||
DirEntries readDirectory(const CanonPath & path) override
|
||||
{
|
||||
DirEntries result;
|
||||
bool exists = false;
|
||||
for (auto & accessor : accessors) {
|
||||
auto st = accessor->maybeLstat(path);
|
||||
if (!st)
|
||||
continue;
|
||||
exists = true;
|
||||
for (auto & entry : accessor->readDirectory(path))
|
||||
// Don't override entries from previous accessors.
|
||||
result.insert(entry);
|
||||
}
|
||||
if (!exists)
|
||||
throw FileNotFound("path '%s' does not exist", showPath(path));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
error:
|
||||
… while evaluating the attribute 'absolutePath'
|
||||
at /pwd/lang/eval-fail-readDir-nonexistent-1.nix:2:3:
|
||||
1| {
|
||||
2| absolutePath = builtins.readDir /this/path/really/should/not/exist;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
… while calling the 'readDir' builtin
|
||||
at /pwd/lang/eval-fail-readDir-nonexistent-1.nix:2:18:
|
||||
1| {
|
||||
2| absolutePath = builtins.readDir /this/path/really/should/not/exist;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
error: path '/this/path/really/should/not/exist' does not exist
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
absolutePath = builtins.readDir /this/path/really/should/not/exist;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
error:
|
||||
… while evaluating the attribute 'relativePath'
|
||||
at /pwd/lang/eval-fail-readDir-nonexistent-2.nix:2:3:
|
||||
1| {
|
||||
2| relativePath = builtins.readDir ./this/path/really/should/not/exist;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
… while calling the 'readDir' builtin
|
||||
at /pwd/lang/eval-fail-readDir-nonexistent-2.nix:2:18:
|
||||
1| {
|
||||
2| relativePath = builtins.readDir ./this/path/really/should/not/exist;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
error: path '/pwd/lang/this/path/really/should/not/exist' does not exist
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
relativePath = builtins.readDir ./this/path/really/should/not/exist;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
error:
|
||||
… while evaluating the attribute 'regularFile'
|
||||
at /pwd/lang/eval-fail-readDir-not-a-directory-1.nix:2:3:
|
||||
1| {
|
||||
2| regularFile = builtins.readDir ./readDir/bar;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
… while calling the 'readDir' builtin
|
||||
at /pwd/lang/eval-fail-readDir-not-a-directory-1.nix:2:17:
|
||||
1| {
|
||||
2| regularFile = builtins.readDir ./readDir/bar;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
error: cannot read directory "/pwd/lang/readDir/bar": Not a directory
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
regularFile = builtins.readDir ./readDir/bar;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
error:
|
||||
… while evaluating the attribute 'symlinkedRegularFile'
|
||||
at /pwd/lang/eval-fail-readDir-not-a-directory-2.nix:2:3:
|
||||
1| {
|
||||
2| symlinkedRegularFile = builtins.readDir ./readDir/linked;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
… while calling the 'readDir' builtin
|
||||
at /pwd/lang/eval-fail-readDir-not-a-directory-2.nix:2:26:
|
||||
1| {
|
||||
2| symlinkedRegularFile = builtins.readDir ./readDir/linked;
|
||||
| ^
|
||||
3| }
|
||||
|
||||
error: cannot read directory "/pwd/lang/readDir/foo/git-hates-directories": Not a directory
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
symlinkedRegularFile = builtins.readDir ./readDir/linked;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ git-hates-directories = "regular"; }
|
||||
@@ -0,0 +1 @@
|
||||
builtins.readDir ./readDir/ldir
|
||||
Reference in New Issue
Block a user