aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval-cache.cc
diff options
context:
space:
mode:
authorQyriad <qyriad@qyriad.me>2024-04-04 10:46:44 -0600
committerjade <lix@jade.fyi>2024-04-06 04:35:25 +0000
commita4ef195a9f4c0e018673a872f8f3020cc5337a36 (patch)
tree0c6dd483a2073130316b49937f6e2d4fab49870f /src/libexpr/eval-cache.cc
parentb47c159aec9aa5d8d1807319123a53f87624fafa (diff)
always re-eval cached failures
This is terrible UX, and frankly an eval failure should be a cache invalidation anyway. This removes the CachedEvalError type entirely. Fixes #223. Change-Id: I91f8003eabd0ea45003024e96d1de3c7ae8e49d8
Diffstat (limited to 'src/libexpr/eval-cache.cc')
-rw-r--r--src/libexpr/eval-cache.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc
index 20dd9e0bc..f26e6d724 100644
--- a/src/libexpr/eval-cache.cc
+++ b/src/libexpr/eval-cache.cc
@@ -469,7 +469,7 @@ Suggestions AttrCursor::getSuggestionsForAttr(Symbol name)
return Suggestions::bestMatches(strAttrNames, root->state.symbols[name]);
}
-std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name, bool forceErrors)
+std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name)
{
if (root->db) {
if (!cachedValue)
@@ -487,10 +487,7 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(Symbol name, bool forceErro
if (std::get_if<missing_t>(&attr->second))
return nullptr;
else if (std::get_if<failed_t>(&attr->second)) {
- if (forceErrors)
- debug("reevaluating failed cached attribute '%s'", getAttrPathStr(name));
- else
- throw CachedEvalError(root->state, "cached failure of attribute '%s'", getAttrPathStr(name));
+ debug("reevaluating failed cached attribute '%s'", getAttrPathStr(name));
} else
return std::make_shared<AttrCursor>(root,
std::make_pair(shared_from_this(), name), nullptr, std::move(attr));
@@ -536,9 +533,9 @@ std::shared_ptr<AttrCursor> AttrCursor::maybeGetAttr(std::string_view name)
return maybeGetAttr(root->state.symbols.create(name));
}
-ref<AttrCursor> AttrCursor::getAttr(Symbol name, bool forceErrors)
+ref<AttrCursor> AttrCursor::getAttr(Symbol name)
{
- auto p = maybeGetAttr(name, forceErrors);
+ auto p = maybeGetAttr(name);
if (!p)
throw Error("attribute '%s' does not exist", getAttrPathStr(name));
return ref(p);
@@ -549,11 +546,11 @@ ref<AttrCursor> AttrCursor::getAttr(std::string_view name)
return getAttr(root->state.symbols.create(name));
}
-OrSuggestions<ref<AttrCursor>> AttrCursor::findAlongAttrPath(const std::vector<Symbol> & attrPath, bool force)
+OrSuggestions<ref<AttrCursor>> AttrCursor::findAlongAttrPath(const std::vector<Symbol> & attrPath)
{
auto res = shared_from_this();
for (auto & attr : attrPath) {
- auto child = res->maybeGetAttr(attr, force);
+ auto child = res->maybeGetAttr(attr);
if (!child) {
auto suggestions = res->getSuggestionsForAttr(attr);
return OrSuggestions<ref<AttrCursor>>::failed(suggestions);
@@ -750,7 +747,7 @@ bool AttrCursor::isDerivation()
StorePath AttrCursor::forceDerivation()
{
- auto aDrvPath = getAttr(root->state.sDrvPath, true);
+ auto aDrvPath = getAttr(root->state.sDrvPath);
auto drvPath = root->state.store->parseStorePath(aDrvPath->getString());
if (!root->state.store->isValidPath(drvPath) && !settings.readOnlyMode) {
/* The eval cache contains 'drvPath', but the actual path has