From 5bb79cb6635272a3725d4b9f9eca8159746cb16e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 5 Feb 2026 17:02:50 +0100 Subject: [PATCH] BinaryCacheStore::queryPathInfoUncached(): Ensure noexcept Make sure we don't throw an exception, since that will terminate the program. --- src/libstore/binary-cache-store.cc | 62 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 848669ae84f9..8ccb1f0bdd43 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -435,37 +435,41 @@ void BinaryCacheStore::narFromPath(const StorePath & storePath, Sink & sink) void BinaryCacheStore::queryPathInfoUncached( const StorePath & storePath, Callback> callback) noexcept { - auto uri = config.getReference().render(/*FIXME withParams=*/false); - auto storePathS = printStorePath(storePath); - auto act = std::make_shared( - *logger, - lvlTalkative, - actQueryPathInfo, - fmt("querying info about '%s' on '%s'", storePathS, uri), - Logger::Fields{storePathS, uri}); - PushActivity pact(act->id); - - auto narInfoFile = narInfoFileFor(storePath); - auto callbackPtr = std::make_shared(std::move(callback)); - getFile(narInfoFile, {[=, this](std::future> fut) { - try { - auto data = fut.get(); - - if (!data) - return (*callbackPtr)({}); - - stats.narInfoRead++; - - (*callbackPtr)( - (std::shared_ptr) std::make_shared(*this, *data, narInfoFile)); - - (void) act; // force Activity into this lambda to ensure it stays alive - } catch (...) { - callbackPtr->rethrow(); - } - }}); + try { + auto uri = config.getReference().render(/*FIXME withParams=*/false); + auto storePathS = printStorePath(storePath); + auto act = std::make_shared( + *logger, + lvlTalkative, + actQueryPathInfo, + fmt("querying info about '%s' on '%s'", storePathS, uri), + Logger::Fields{storePathS, uri}); + PushActivity pact(act->id); + + auto narInfoFile = narInfoFileFor(storePath); + + getFile(narInfoFile, {[=, this](std::future> fut) { + try { + auto data = fut.get(); + + if (!data) + return (*callbackPtr)({}); + + stats.narInfoRead++; + + (*callbackPtr)( + (std::shared_ptr) std::make_shared(*this, *data, narInfoFile)); + + (void) act; // force Activity into this lambda to ensure it stays alive + } catch (...) { + callbackPtr->rethrow(); + } + }}); + } catch (...) { + callbackPtr->rethrow(); + } } StorePath BinaryCacheStore::addToStore(