libstore: pass only data to TransferItem data callback

with encoding being handled by curl the reference is no longer needed.

Change-Id: Ibfaf5f55e5314e81ce45ba4523b960c401dd2e1c
This commit is contained in:
eldritch horrors 2024-10-28 18:59:43 +01:00
parent 10488f7431
commit 64864c3730

View file

@ -63,7 +63,7 @@ struct curlFileTransfer : public FileTransfer
std::packaged_task< std::packaged_task<
std::pair<FileTransferResult, std::string>(std::exception_ptr, FileTransferResult)> std::pair<FileTransferResult, std::string>(std::exception_ptr, FileTransferResult)>
callback; callback;
std::function<void(TransferItem &, std::string_view data)> dataCallback; std::function<void(std::string_view data)> dataCallback;
CURL * req; // must never be nullptr CURL * req; // must never be nullptr
std::string statusMsg; std::string statusMsg;
@ -103,7 +103,7 @@ struct curlFileTransfer : public FileTransfer
const Headers & headers, const Headers & headers,
ActivityId parentAct, 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(std::string_view data)> dataCallback,
std::optional<std::string> uploadData, std::optional<std::string> uploadData,
bool noBody bool noBody
) )
@ -196,7 +196,7 @@ struct curlFileTransfer : public FileTransfer
if (successfulStatuses.count(getHTTPStatus()) && this->dataCallback) { if (successfulStatuses.count(getHTTPStatus()) && this->dataCallback) {
writtenToSink += realSize; writtenToSink += realSize;
dataCallback(*this, {static_cast<const char *>(contents), realSize}); dataCallback({static_cast<const char *>(contents), realSize});
} else { } else {
this->downloadData.append(static_cast<const char *>(contents), realSize); this->downloadData.append(static_cast<const char *>(contents), realSize);
} }
@ -732,7 +732,7 @@ struct curlFileTransfer : public FileTransfer
const std::string & uri, const std::string & uri,
const Headers & headers, const Headers & headers,
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(std::string_view data)> dataCallback,
std::optional<std::string> data, std::optional<std::string> data,
bool noBody bool noBody
) )
@ -816,7 +816,7 @@ struct curlFileTransfer : public FileTransfer
state->avail.notify_one(); state->avail.notify_one();
state->request.notify_one(); state->request.notify_one();
}, },
[_state](TransferItem & transfer, std::string_view data) { [_state](std::string_view data) {
auto state(_state->lock()); auto state(_state->lock());
if (state->failed) { if (state->failed) {