aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-07 04:06:03 +0100
committereldritch horrors <pennae@lix.systems>2024-03-07 00:43:51 -0700
commitb14f88e0d46c61280a69da9559cf54cbce058eb5 (patch)
tree7b1c0be985b3f1aa7ae86ee1727d7a08c36c11a5 /src/libexpr/primops.cc
parent1342c8f18e48afd1577cfdc319c254ce7c42637e (diff)
Merge pull request #9985 from alois31/symlink-resolution
Restore `builtins.pathExists` behavior on broken symlinks (cherry picked from commit d53c8901ef7f2033855dd99063522e3d56a19dab) === note that this variant differs markedly from the source commit because we haven't endured quite as much lazy trees. Change-Id: I0facf282f21fe0db4134be5c65a8368c1b3a06fc
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 1a961582f..c4fdc6098 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1540,11 +1540,12 @@ static void prim_pathExists(EvalState & state, const PosIdx pos, Value * * args,
|| arg.str().ends_with("/."));
try {
- auto checked = state.checkSourcePath(path);
- auto exists = checked.pathExists();
- if (exists && mustBeDir) {
- exists = checked.lstat().type == InputAccessor::tDirectory;
- }
+ auto checked = state
+ .checkSourcePath(path)
+ .resolveSymlinks(mustBeDir ? SymlinkResolution::Full : SymlinkResolution::Ancestors);
+
+ auto st = checked.maybeLstat();
+ auto exists = st && (!mustBeDir || st->type == InputAccessor::tDirectory);
v.mkBool(exists);
} catch (SysError & e) {
/* Don't give away info from errors while canonicalising