From 201c0d5b7fb85924b7dec34ffbab2977b4a67f0d Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 1 Mar 2025 23:55:42 +0100 Subject: [PATCH] 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 --- lix/libstore/local-store.cc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lix/libstore/local-store.cc b/lix/libstore/local-store.cc index 10b66a475..083169950 100644 --- a/lix/libstore/local-store.cc +++ b/lix/libstore/local-store.cc @@ -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();