mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
libexpr: Use Store::requireStoreObjectAccessor instead or toRealPath in fetch
This forces the code to go through proper abstractions instead of the raw filesystem
API.
This issue is evident from this reproducer:
nix eval --expr 'builtins.fetchurl { url = "https://example.com"; sha256 = ""; }' --json --eval-store "dummy://?read-only=false"
error:
… while calling the 'fetchurl' builtin
at «string»:1:1:
1| builtins.fetchurl { url = "https://example.com"; sha256 = ""; }
| ^
error: opening file '/nix/store/r4f87yrl98f2m6v9z8ai2rbg4qwlcakq-example.com': No such file or directory
This commit is contained in:
parent
69c005e805
commit
918a3cebaa
1 changed files with 5 additions and 1 deletions
|
|
@ -588,7 +588,11 @@ static void fetch(
|
||||||
|
|
||||||
if (expectedHash) {
|
if (expectedHash) {
|
||||||
auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash
|
auto hash = unpack ? state.store->queryPathInfo(storePath)->narHash
|
||||||
: hashFile(HashAlgorithm::SHA256, state.store->toRealPath(storePath));
|
: hashPath(
|
||||||
|
{state.store->requireStoreObjectAccessor(storePath)},
|
||||||
|
FileSerialisationMethod::Flat,
|
||||||
|
HashAlgorithm::SHA256)
|
||||||
|
.hash;
|
||||||
if (hash != *expectedHash) {
|
if (hash != *expectedHash) {
|
||||||
state
|
state
|
||||||
.error<EvalError>(
|
.error<EvalError>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue