1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 23:13:14 +02:00

Fix decoding virtual paths that are at the root of the tree

This commit is contained in:
Eelco Dolstra 2022-11-25 17:50:44 +01:00
parent b27cd882ac
commit 515b908690
2 changed files with 4 additions and 3 deletions

View file

@ -40,9 +40,8 @@ SourcePath EvalState::decodePath(std::string_view s, PosIdx pos)
try {
auto slash = s.find('/');
if (slash == std::string::npos) fail();
size_t number = std::stoi(std::string(s, 0, slash), nullptr, 16);
s = s.substr(slash);
size_t number = std::stoi(std::string(s.substr(0, slash)), nullptr, 16);
s = slash == s.npos ? "" : s.substr(slash);
auto accessor = inputAccessors.find(number);
if (accessor == inputAccessors.end()) fail();

View file

@ -4,3 +4,5 @@ mkdir -p $TEST_ROOT/foo
echo bla > $TEST_ROOT/foo/bar
[[ $(nix eval --raw --impure --expr "builtins.readFile (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; } + \"bar\"))") = bla ]]
[[ $(nix eval --json --impure --expr "builtins.readDir (builtins.toString (builtins.fetchTree { type = \"path\"; path = \"$TEST_ROOT/foo\"; }))") = '{"bar":"regular"}' ]]