Bug 398218 - Download DB tracks -1 as the max size when resuming. r=sdwilsh, a=mconnor
--- a/toolkit/components/downloads/src/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/src/nsDownloadManager.cpp
@@ -820,17 +820,19 @@ nsDownloadManager::GetDownloadFromDB(PRU
if (NS_SUCCEEDED(rv) && !referrer.IsEmpty()) {
rv = NS_NewURI(getter_AddRefs(dl->mReferrer), referrer);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = stmt->GetUTF8String(i++, dl->mEntityID);
NS_ENSURE_SUCCESS(rv, rv);
- dl->SetProgressBytes(stmt->AsInt64(i++), stmt->AsInt64(i++));
+ PRInt64 currBytes = stmt->AsInt64(i++);
+ PRInt64 maxBytes = stmt->AsInt64(i++);
+ dl->SetProgressBytes(currBytes, maxBytes);
// Addrefing and returning
NS_ADDREF(*retVal = dl);
return NS_OK;
}
nsresult
nsDownloadManager::AddToCurrentDownloads(nsDownload *aDl)
@@ -2189,20 +2191,22 @@ nsDownload::RealResume()
// Set the channel to resume at the right position along with the entityID
nsCOMPtr<nsIResumableChannel> resumableChannel(do_QueryInterface(channel));
if (!resumableChannel)
return NS_ERROR_UNEXPECTED;
rv = resumableChannel->ResumeAt(fileSize, mEntityID);
NS_ENSURE_SUCCESS(rv, rv);
+ // If we know the max size, we know what it should be when resuming
+ PRInt64 maxBytes;
+ GetSize(&maxBytes);
+ SetProgressBytes(0, maxBytes != -1 ? maxBytes - fileSize : -1);
// Track where we resumed because progress notifications restart at 0
mResumedAt = fileSize;
- mCurrBytes = 0;
- mMaxBytes = -1;
// Set the referrer
if (mReferrer) {
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
if (httpChannel) {
rv = httpChannel->SetReferrer(mReferrer);
NS_ENSURE_SUCCESS(rv, rv);
}