Fix - download progress resets to zero momentarily on download items when a new download begins

- Downloads window displays "0%" in the title bar progress briefly after a download completes.
This commit is contained in:
ben%bengoodger.com 2003-12-21 02:54:48 +00:00
Родитель 5fa2d26357
Коммит dd49d5d888
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -529,6 +529,13 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
nsCOMPtr<nsIRDFResource> downloadRes;
gRDFService->GetUnicodeResource(path, getter_AddRefs(downloadRes));
// Save state of existing downloads NOW... because inserting the new
// download resource into the container will cause the FE to rebuild and all
// the active downloads will have their progress reset (since progress is held
// mostly by the FE and not the datasource) until they get another progress
// notification (which could be a while for slow downloads).
SaveState();
// if the resource is in the container already (the user has already
// downloaded this file), remove it
PRInt32 itemIndex;

Просмотреть файл

@ -407,6 +407,7 @@ function onUpdateProgress()
var numActiveDownloads = gActiveDownloads.length;
if (numActiveDownloads == 0) {
window.title = document.documentElement.getAttribute("statictitle");
gLastComputedMean = 0;
return;
}
@ -419,6 +420,15 @@ function onUpdateProgress()
}
mean = Math.round(mean / numActiveDownloads);
// At the end of a download, progress is set from 100% to 0% for
// some reason. We can identify this case because at this point the
// mean progress will be zero but the last computed mean will be
// greater than zero.
if (mean == 0 && gLastComputedMean > 0) {
window.title = document.documentElement.getAttribute("statictitle");
return;
}
if (mean != gLastComputedMean) {
gLastComputedMean = mean;
var strings = document.getElementById("downloadStrings");