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
This commit is contained in:
eldritch horrors 2024-10-26 17:11:18 +02:00
parent ce3e1d1e7a
commit 1e3b45546c
2 changed files with 11 additions and 8 deletions

View file

@ -87,6 +87,7 @@ struct curlFileTransfer : public FileTransfer
TransferItem(curlFileTransfer & fileTransfer, TransferItem(curlFileTransfer & fileTransfer,
const FileTransferRequest & request, const FileTransferRequest & request,
ActivityId parentAct,
std::invocable<std::exception_ptr> auto callback, std::invocable<std::exception_ptr> auto callback,
std::function<void(TransferItem &, std::string_view data)> dataCallback, std::function<void(TransferItem &, std::string_view data)> dataCallback,
std::optional<std::string> uploadData std::optional<std::string> uploadData
@ -95,7 +96,7 @@ struct curlFileTransfer : public FileTransfer
, request(request) , request(request)
, act(*logger, lvlTalkative, actFileTransfer, , act(*logger, lvlTalkative, actFileTransfer,
fmt(uploadData ? "uploading '%s'" : "downloading '%s'", request.uri), fmt(uploadData ? "uploading '%s'" : "downloading '%s'", request.uri),
{request.uri}, request.parentAct) {request.uri}, parentAct)
, uploadData(std::move(uploadData)) , uploadData(std::move(uploadData))
, callback([cb{std::move(callback)}] (std::exception_ptr ex, FileTransferResult r) { , callback([cb{std::move(callback)}] (std::exception_ptr ex, FileTransferResult r) {
cb(ex); cb(ex);
@ -714,11 +715,14 @@ struct curlFileTransfer : public FileTransfer
}); });
} }
return enqueueItem( return enqueueItem(std::make_shared<TransferItem>(
std::make_shared<TransferItem>( *this,
*this, request, std::move(callback), std::move(dataCallback), std::move(data) request,
) getCurActivity(),
) std::move(callback),
std::move(dataCallback),
std::move(data)
))
->callback.get_future(); ->callback.get_future();
} }

View file

@ -61,10 +61,9 @@ struct FileTransferRequest
bool head = false; bool head = false;
size_t tries = fileTransferSettings.tries; size_t tries = fileTransferSettings.tries;
unsigned int baseRetryTimeMs = 250; unsigned int baseRetryTimeMs = 250;
ActivityId parentAct;
FileTransferRequest(std::string_view uri) FileTransferRequest(std::string_view uri)
: uri(uri), parentAct(getCurActivity()) { } : uri(uri) { }
}; };
struct FileTransferResult struct FileTransferResult