aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/flake/flake.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-11-15 18:44:27 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-11-15 18:44:27 +0100
commit671817a858875045b5f99a15ac92addaf9b207f5 (patch)
treeb9ab6659e90b83f47dfbe09f3b06514485d21281 /src/libexpr/flake/flake.cc
parentd1d223838bcd30dce7cbd7fddbce3fc6beb5fb3e (diff)
Simplify lockFlake() a bit
Diffstat (limited to 'src/libexpr/flake/flake.cc')
-rw-r--r--src/libexpr/flake/flake.cc27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 1dc6f5694..f5be67d67 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -446,24 +446,18 @@ LockedFlake lockFlake(
update it. */
auto lb = lockFlags.inputUpdates.lower_bound(inputPath);
- auto hasChildUpdate =
+ auto mustRefetch =
lb != lockFlags.inputUpdates.end()
&& lb->size() > inputPath.size()
&& std::equal(inputPath.begin(), inputPath.end(), lb->begin());
- if (hasChildUpdate) {
- auto inputFlake = getFlake(
- state, oldLock->lockedRef, false, flakeCache);
- computeLocks(inputFlake.inputs, childNode, inputPath, oldLock, parent, parentPath);
- } else {
+ FlakeInputs fakeInputs;
+
+ if (!mustRefetch) {
/* No need to fetch this flake, we can be
lazy. However there may be new overrides on the
inputs of this flake, so we need to check
those. */
- FlakeInputs fakeInputs;
-
- bool refetch = false;
-
for (auto & i : oldLock->inputs) {
if (auto lockedNode = std::get_if<0>(&i.second)) {
fakeInputs.emplace(i.first, FlakeInput {
@@ -475,7 +469,7 @@ LockedFlake lockFlake(
// If the override disappeared, we have to refetch the flake,
// since some of the inputs may not be present in the lockfile.
if (o == input.overrides.end()) {
- refetch = true;
+ mustRefetch = true;
// There's no point populating the rest of the fake inputs,
// since we'll refetch the flake anyways.
break;
@@ -485,13 +479,14 @@ LockedFlake lockFlake(
});
}
}
-
- if (refetch)
- fakeInputs = getFlake(state, oldLock->lockedRef, false, flakeCache).inputs;
-
- computeLocks(fakeInputs, childNode, inputPath, oldLock, parent, parentPath);
}
+ computeLocks(
+ mustRefetch
+ ? getFlake(state, oldLock->lockedRef, false, flakeCache).inputs
+ : fakeInputs,
+ childNode, inputPath, oldLock, parent, parentPath);
+
} else {
/* We need to create a new lock file entry. So fetch
this input. */