From 1e3b45546cb4820c0df422b2353a2bee014f699e Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sat, 26 Oct 2024 17:11:18 +0200 Subject: [PATCH] libstore: remove FileTransferRequest::parentAct never set explicitly, and transfers are never instantiated with one current activity but submitted with a *different* current activity. Change-Id: I1a3ec57c02013565aeb9e9398ea42d0c4279095e --- src/libstore/filetransfer.cc | 16 ++++++++++------ src/libstore/filetransfer.hh | 3 +-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index 394834ad6..82961e547 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -87,6 +87,7 @@ struct curlFileTransfer : public FileTransfer TransferItem(curlFileTransfer & fileTransfer, const FileTransferRequest & request, + ActivityId parentAct, std::invocable auto callback, std::function dataCallback, std::optional uploadData @@ -95,7 +96,7 @@ struct curlFileTransfer : public FileTransfer , request(request) , act(*logger, lvlTalkative, actFileTransfer, fmt(uploadData ? "uploading '%s'" : "downloading '%s'", request.uri), - {request.uri}, request.parentAct) + {request.uri}, parentAct) , uploadData(std::move(uploadData)) , callback([cb{std::move(callback)}] (std::exception_ptr ex, FileTransferResult r) { cb(ex); @@ -714,11 +715,14 @@ struct curlFileTransfer : public FileTransfer }); } - return enqueueItem( - std::make_shared( - *this, request, std::move(callback), std::move(dataCallback), std::move(data) - ) - ) + return enqueueItem(std::make_shared( + *this, + request, + getCurActivity(), + std::move(callback), + std::move(dataCallback), + std::move(data) + )) ->callback.get_future(); } diff --git a/src/libstore/filetransfer.hh b/src/libstore/filetransfer.hh index 3d277c761..38a9243ad 100644 --- a/src/libstore/filetransfer.hh +++ b/src/libstore/filetransfer.hh @@ -61,10 +61,9 @@ struct FileTransferRequest bool head = false; size_t tries = fileTransferSettings.tries; unsigned int baseRetryTimeMs = 250; - ActivityId parentAct; FileTransferRequest(std::string_view uri) - : uri(uri), parentAct(getCurActivity()) { } + : uri(uri) { } }; struct FileTransferResult