Fix: reset content download progress to zero if falling back to TCP

Otherwise this chain of events can happen:
- You already have a (partial) file downloaded
- You start the download, and HTTP fails
- This resets the download progress to the current size of the file
- The TCP download starts at a very large value (UINT32_MAX - filesize)

It now resets to 0% done when any negative value is being given.
As added bonus, we no longer have to query how much was already
downloaded.
This commit is contained in:
Patric Stout
2023-02-15 20:51:58 +01:00
committed by Patric Stout
parent 1c17556f96
commit dea2dea881
2 changed files with 9 additions and 5 deletions

View File

@@ -586,9 +586,7 @@ void ClientNetworkContentSocketHandler::OnFailure()
this->http_response_index = -2;
if (this->curFile != nullptr) {
/* Revert the download progress when we are going for the old system. */
long size = ftell(this->curFile);
if (size > 0) this->OnDownloadProgress(this->curInfo, (int)-size);
this->OnDownloadProgress(this->curInfo, -1);
fclose(this->curFile);
this->curFile = nullptr;