Skip to content

Commit b3dfe37

Browse files
committed
libstore/filetransfer: Handle exceptions in progressCallback
1 parent 87d3c3b commit b3dfe37

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/libstore/filetransfer.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,17 @@ struct curlFileTransfer : public FileTransfer
277277
return ((TransferItem *) userp)->headerCallback(contents, size, nmemb);
278278
}
279279

280-
int progressCallback(curl_off_t dltotal, curl_off_t dlnow)
281-
{
282-
try {
283-
act.progress(dlnow, dltotal);
284-
} catch (nix::Interrupted &) {
285-
assert(getInterrupted());
286-
}
280+
int progressCallback(curl_off_t dltotal, curl_off_t dlnow) noexcept
281+
try {
282+
act.progress(dlnow, dltotal);
287283
return getInterrupted();
284+
} catch (nix::Interrupted &) {
285+
assert(getInterrupted());
286+
return 1;
287+
} catch (...) {
288+
/* Something unexpected has happened like logger throwing an exception. */
289+
callbackException = std::current_exception();
290+
return 1;
288291
}
289292

290293
static int progressCallbackWrapper(

0 commit comments

Comments
 (0)