mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
Don't mark inputs as final in getAccessorUnchecked()
We haven't added the narHash attribute yet at that point. And if the caller uses getAccesor() instead of fetchToStore() (e.g. in `nix registry pin`), the narHash attribute will never be added. This could lead to a mismatch.
This commit is contained in:
parent
fc09815eda
commit
ed1f9dd13f
1 changed files with 8 additions and 4 deletions
|
@ -185,6 +185,14 @@ std::pair<StorePath, Input> Input::fetchToStore(ref<Store> store) const
|
||||||
auto narHash = store->queryPathInfo(storePath)->narHash;
|
auto narHash = store->queryPathInfo(storePath)->narHash;
|
||||||
final.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
final.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
|
||||||
|
|
||||||
|
// FIXME: we would like to mark inputs as final in
|
||||||
|
// getAccessorUnchecked(), but then we can't add
|
||||||
|
// narHash. Or maybe narHash should be excluded from the
|
||||||
|
// concept of "final" inputs?
|
||||||
|
final.attrs.insert_or_assign("final", Explicit<bool>(true));
|
||||||
|
|
||||||
|
assert(final.isFinal());
|
||||||
|
|
||||||
scheme->checkLocks(*this, final);
|
scheme->checkLocks(*this, final);
|
||||||
|
|
||||||
return {storePath, final};
|
return {storePath, final};
|
||||||
|
@ -228,8 +236,6 @@ void InputScheme::checkLocks(const Input & specified, const Input & final) const
|
||||||
final.to_string(), *prevRevCount);
|
final.to_string(), *prevRevCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(final.isFinal());
|
|
||||||
|
|
||||||
if (specified.isFinal() && specified.attrs != final.attrs)
|
if (specified.isFinal() && specified.attrs != final.attrs)
|
||||||
throw Error("fetching final input '%s' resulted in different input '%s'",
|
throw Error("fetching final input '%s' resulted in different input '%s'",
|
||||||
attrsToJSON(specified.attrs), attrsToJSON(final.attrs));
|
attrsToJSON(specified.attrs), attrsToJSON(final.attrs));
|
||||||
|
@ -291,8 +297,6 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
|
||||||
assert(!accessor->fingerprint);
|
assert(!accessor->fingerprint);
|
||||||
accessor->fingerprint = scheme->getFingerprint(store, final);
|
accessor->fingerprint = scheme->getFingerprint(store, final);
|
||||||
|
|
||||||
final.attrs.insert_or_assign("final", Explicit<bool>(true));
|
|
||||||
|
|
||||||
return {accessor, std::move(final)};
|
return {accessor, std::move(final)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue