mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
fix(libfetchers): substitute fetchTarball and fetchurl
Fixes #4313 by enabling builtins.fetchurl, builtins.fetchTarball to use binary cache substituters before attempting to download from the original URL.
This commit is contained in:
parent
30a6cbe90b
commit
1e92b61750
3 changed files with 189 additions and 3 deletions
|
|
@ -561,14 +561,22 @@ static void fetch(
|
|||
.hash = *expectedHash,
|
||||
.references = {}});
|
||||
|
||||
if (state.store->isValidPath(expectedPath)) {
|
||||
// Try to get the path from the local store or substituters
|
||||
try {
|
||||
state.store->ensurePath(expectedPath);
|
||||
debug("using substituted/cached path '%s' for '%s'", state.store->printStorePath(expectedPath), *url);
|
||||
state.allowAndSetStorePathString(expectedPath, v);
|
||||
return;
|
||||
} catch (Error & e) {
|
||||
debug(
|
||||
"substitution of '%s' failed, will try to download: %s",
|
||||
state.store->printStorePath(expectedPath),
|
||||
e.what());
|
||||
// Fall through to download
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: fetching may fail, yet the path may be substitutable.
|
||||
// https://github.com/NixOS/nix/issues/4313
|
||||
// Download the file/tarball if substitution failed or no hash was provided
|
||||
auto storePath = unpack ? fetchToStore(
|
||||
state.fetchSettings,
|
||||
*state.store,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue