fetchTree: Use isValidPath, add comment

This commit is contained in:
Robert Hensing 2022-03-01 12:11:10 +01:00
parent ee019d0afc
commit b6deca7c0d

View file

@ -239,13 +239,14 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
? state.store->makeFixedOutputPath(FileIngestionMethod::Recursive, *expectedHash, name, {})
: state.store->makeFixedOutputPath(FileIngestionMethod::Flat, *expectedHash, name, {});
auto validPaths = state.store->queryValidPaths({expectedPath}, NoSubstitute);
if (!validPaths.empty()) {
if (state.store->isValidPath(expectedPath)) {
state.allowAndSetStorePathString(expectedPath, v);
return;
}
}
// TODO: fetching may fail, yet the path may be substitutable.
// https://github.com/NixOS/nix/issues/4313
auto storePath =
unpack
? fetchers::downloadTarball(state.store, *url, name, (bool) expectedHash).first.storePath