зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
5fa2d26357
Коммит
dd49d5d888
|
@ -529,6 +529,13 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
|
||||||
nsCOMPtr<nsIRDFResource> downloadRes;
|
nsCOMPtr<nsIRDFResource> downloadRes;
|
||||||
gRDFService->GetUnicodeResource(path, getter_AddRefs(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
|
// if the resource is in the container already (the user has already
|
||||||
// downloaded this file), remove it
|
// downloaded this file), remove it
|
||||||
PRInt32 itemIndex;
|
PRInt32 itemIndex;
|
||||||
|
|
|
@ -407,6 +407,7 @@ function onUpdateProgress()
|
||||||
var numActiveDownloads = gActiveDownloads.length;
|
var numActiveDownloads = gActiveDownloads.length;
|
||||||
if (numActiveDownloads == 0) {
|
if (numActiveDownloads == 0) {
|
||||||
window.title = document.documentElement.getAttribute("statictitle");
|
window.title = document.documentElement.getAttribute("statictitle");
|
||||||
|
gLastComputedMean = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,6 +420,15 @@ function onUpdateProgress()
|
||||||
}
|
}
|
||||||
|
|
||||||
mean = Math.round(mean / numActiveDownloads);
|
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) {
|
if (mean != gLastComputedMean) {
|
||||||
gLastComputedMean = mean;
|
gLastComputedMean = mean;
|
||||||
var strings = document.getElementById("downloadStrings");
|
var strings = document.getElementById("downloadStrings");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче