Skip to content

Commit

Permalink
Merge pull request #11604 from NixOS/mergify/bp/2.24-maintenance/pr-1…
Browse files Browse the repository at this point in the history
…1600

HttpBinaryCacheStore::getFile(): Fix uncaught exception (backport #11600)
  • Loading branch information
edolstra authored Sep 27, 2024
2 parents b23812a + 15a2b49 commit 048cfe5
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,29 @@ class HttpBinaryCacheStore : public virtual HttpBinaryCacheStoreConfig, public v
{
try {
checkEnabled();

auto request(makeRequest(path));

auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));

getFileTransfer()->enqueueFileTransfer(request,
{[callbackPtr, this](std::future<FileTransferResult> result) {
try {
(*callbackPtr)(std::move(result.get().data));
} catch (FileTransferError & e) {
if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden)
return (*callbackPtr)({});
maybeDisable();
callbackPtr->rethrow();
} catch (...) {
callbackPtr->rethrow();
}
}});

} catch (...) {
callback.rethrow();
return;
}

auto request(makeRequest(path));

auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));

getFileTransfer()->enqueueFileTransfer(request,
{[callbackPtr, this](std::future<FileTransferResult> result) {
try {
(*callbackPtr)(std::move(result.get().data));
} catch (FileTransferError & e) {
if (e.error == FileTransfer::NotFound || e.error == FileTransfer::Forbidden)
return (*callbackPtr)({});
maybeDisable();
callbackPtr->rethrow();
} catch (...) {
callbackPtr->rethrow();
}
}});
}

/**
Expand Down

0 comments on commit 048cfe5

Please sign in to comment.