BACKENDS: NETWORKING: Fix local file downloading when stream is reused

This commit is contained in:
Eugene Sandulenko 2021-11-18 22:37:24 +01:00
parent 4e32936376
commit 1507559a66
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -62,6 +62,8 @@ void SessionRequest::openLocalFile(Common::String localFile) {
return;
}
debug(5, "SessionRequest: opened localfile %s", localFile.c_str());
_binary = true; // Enforce binary
}
@ -105,6 +107,11 @@ void SessionRequest::finishSuccess() {
_complete = true;
_success = true;
if (_localFile) {
_localFile->close();
_localFile = nullptr;
}
if (_callback) { // If localfile is present, contentStream is empty, so it is fine
_response.buffer = _contentsStream.getData();
_response.len = _contentsStream.size();
@ -112,11 +119,6 @@ void SessionRequest::finishSuccess() {
(*_callback)(DataResponse(this, &_response));
}
if (_localFile) {
_localFile->close();
_localFile = nullptr;
}
}
void SessionRequest::start() {