forked from lix-project/lix
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
This commit is contained in:
parent
121edecf65
commit
f75d0752ce
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue