libstore: more explicitly discard uninteresting nar

this wasn't fully correct to begin with; if restorePath threw an
exception we would not have discarded the nar, but if deletePath
threw an exception we would have. discarding the nar in this way
also lets us not swallow nar parser exceptions when adding a nar
for a valid path, potentially notifying clients of corruption in
their own data sources. ideally we would never read the nar when
we're not interested anyway, but that needs a new wire protocol.

Change-Id: Ie5e10a9bee05b67ec2adb9c4f7c9319a4e644e31
This commit is contained in:
eldritch horrors
2025-03-03 03:04:49 +01:00
parent 338f624220
commit 201c0d5b7f
+5 -10
View File
@@ -1214,16 +1214,6 @@ try {
/* In case we are not interested in reading the NAR: discard it. */
bool narRead = false;
Finally cleanup = [&]() {
if (!narRead) {
try {
auto copy = copyNAR(source);
while (copy.next()) {}
} catch (...) {
ignoreExceptionExceptInterrupt();
}
}
};
TRY_AWAIT(addTempRoot(info.path));
@@ -1286,6 +1276,11 @@ try {
registerValidPath(info);
}
}
if (!narRead) {
auto copy = copyNAR(source);
while (copy.next()) {}
}
co_return result::success();
} catch (...) {
co_return result::current_exception();