aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-05-06 16:46:11 +0200
committereldritch horrors <pennae@lix.systems>2024-05-06 21:18:23 +0200
commitf75d0752ce8fa156feb92b2b31f4f3326f65476b (patch)
tree4194dac460ad5c6e42e0e57b6860866baa039be6
parent121edecf654ec084274ba1a779c7140082f4115d (diff)
filetransfer: correctly abort empty transfers
returning 0 from the callback for errors signals successful transfer if the source returned no data even though the exception we've just caught clearly disagrees. while this is not all that important (since the only viable cause of such errors will be dataCallback, and the sole instance of it being used already takes care of exceptions) we can just do this. Change-Id: I2bb150eff447121d82e8e3aa4e00057c40523ac6
-rw-r--r--src/libstore/filetransfer.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index a0e3fd586..67b9fef81 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -149,6 +149,8 @@ struct curlFileTransfer : public FileTransfer
size_t writeCallback(void * contents, size_t size, size_t nmemb)
{
+ const size_t realSize = size * nmemb;
+
try {
if (!headersProcessed) {
if (auto h = getHeader("content-encoding")) {
@@ -161,7 +163,6 @@ struct curlFileTransfer : public FileTransfer
headersProcessed = true;
}
- size_t realSize = size * nmemb;
result.bodySize += realSize;
if (successfulStatuses.count(getHTTPStatus()) && this->dataCallback) {
@@ -174,7 +175,7 @@ struct curlFileTransfer : public FileTransfer
return realSize;
} catch (...) {
writeException = std::current_exception();
- return 0;
+ return CURL_WRITEFUNC_ERROR;
}
}