1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00
This commit is contained in:
Philip Wilk 2025-06-21 08:09:57 +02:00 committed by GitHub
commit 02e8b39886
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 12 deletions

View file

@ -80,14 +80,22 @@ Goal::Co PathSubstitutionGoal::init()
continue; continue;
} }
auto path = subPath ? *subPath : storePath;
try { try {
// FIXME: make async // FIXME: make async
info = sub->queryPathInfo(subPath ? *subPath : storePath); info = sub->queryPathInfo(path);
} catch (InvalidPath &) { } catch (InvalidPath &) {
continue; continue;
// Because the substituter has failed recently
} catch (SubstituterDisabled & e) { } catch (SubstituterDisabled & e) {
if (settings.tryFallback) continue; /* This is also VERY spammy
else throw e; warn(
"Substituter '%s' was disabled when getting info for path '%s'",
sub->getUri(),
sub->printStorePath(path));
*/
continue;
// Any other error
} catch (Error & e) { } catch (Error & e) {
if (settings.tryFallback) { if (settings.tryFallback) {
logError(e.info()); logError(e.info());

View file

@ -97,13 +97,11 @@ protected:
void maybeDisable() void maybeDisable()
{ {
auto state(_state.lock()); auto state(_state.lock());
if (state->enabled && settings.tryFallback) {
int t = 60; int t = 60;
printError("disabling binary cache '%s' for %s seconds", getUri(), t); warn("disabling binary cache '%s' for %s seconds", getUri(), t);
state->enabled = false; state->enabled = false;
state->disabledUntil = std::chrono::steady_clock::now() + std::chrono::seconds(t); state->disabledUntil = std::chrono::steady_clock::now() + std::chrono::seconds(t);
} }
}
void checkEnabled() void checkEnabled()
{ {

View file

@ -520,7 +520,8 @@ StorePathSet Store::queryDerivationOutputs(const StorePath & path)
void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, SubstitutablePathInfos & infos) void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, SubstitutablePathInfos & infos)
{ {
if (!settings.useSubstitutes) return; if (!settings.useSubstitutes) return;
for (auto & sub : getDefaultSubstituters()) { auto substituters = getDefaultSubstituters();
for (auto & sub : substituters) {
for (auto & path : paths) { for (auto & path : paths) {
if (infos.count(path.first)) if (infos.count(path.first))
// Choose first succeeding substituter. // Choose first succeeding substituter.
@ -557,10 +558,19 @@ void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, Substituta
} catch (InvalidPath &) { } catch (InvalidPath &) {
} catch (SubstituterDisabled &) { } catch (SubstituterDisabled &) {
} catch (Error & e) { } catch (Error & e) {
if (settings.tryFallback) // if last substituter, THEN log error and throw, otherwise warn
if (&sub == &substituters.back() && !settings.tryFallback) {
logError(e.info()); logError(e.info());
else
throw; throw;
} else {
/* This gets VERY spammy
warn( "Unable to download '%s' from subsituter '%s'\n%s",
sub->printStorePath(subPath),
sub->getUri(),
e.message());
*/
continue;
}
} }
} }
} }