Bug 260741 Wrong download file size in MB is reported

p=gavin.sharp@gmail.com r=mconnor
This commit is contained in:
bugzilla%arlen.demon.co.uk 2005-01-03 00:59:03 +00:00
Родитель f60706e4d8
Коммит 968c1326e2
1 изменённых файлов: 12 добавлений и 12 удалений

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

@ -9,9 +9,9 @@ function DownloadProgressListener (aDocument, aStringBundle)
this._statusFormatKBMB = aStringBundle.getString("statusFormatKBMB");
this._statusFormatKBKB = aStringBundle.getString("statusFormatKBKB");
this._statusFormatMBMB = aStringBundle.getString("statusFormatMBMB");
this._statusFormatUnknownMB = aStringBundle.getString("statusFormatUnknownMB");
this._statusFormatUnknownKB = aStringBundle.getString("statusFormatUnknownKB");
this._remain = aStringBundle.getString("remain");
this._statusFormatUnknownMB = aStringBundle.getString("statusFormatUnknownMB");
this._statusFormatUnknownKB = aStringBundle.getString("statusFormatUnknownKB");
this._remain = aStringBundle.getString("remain");
this._unknownFilesize = aStringBundle.getString("unknownFilesize");
this._longTimeFormat = aStringBundle.getString("longTimeFormat");
this._shortTimeFormat = aStringBundle.getString("shortTimeFormat");
@ -56,7 +56,7 @@ DownloadProgressListener.prototype =
this.elapsed = now - (aDownload.startTime / 1000);
var rate; // aCurTotalProgress/sec
if (this.elapsed)
rate = (aCurTotalProgress * 1000) / this.elapsed;
rate = (aCurTotalProgress * 1024) / this.elapsed;
else
rate = 0;
@ -174,8 +174,8 @@ DownloadProgressListener.prototype =
// x, >= 1MB y >= 1MB x of y MB
_formatKBytes: function (aKBytes, aTotalKBytes)
{
var progressHasMB = parseInt(aKBytes/1000) > 0;
var totalHasMB = parseInt(aTotalKBytes/1000) > 0;
var progressHasMB = parseInt(aKBytes/1024) > 0;
var totalHasMB = parseInt(aTotalKBytes/1024) > 0;
var format = "";
if (!progressHasMB && !totalHasMB) {
@ -184,17 +184,17 @@ DownloadProgressListener.prototype =
}
else if (progressHasMB && totalHasMB) {
format = this._statusFormatMBMB;
format = this._replaceInsert(format, 1, (aKBytes / 1000).toFixed(1));
format = this._replaceInsert(format, 2, (aTotalKBytes / 1000).toFixed(1));
format = this._replaceInsert(format, 1, (aKBytes / 1024).toFixed(1));
format = this._replaceInsert(format, 2, (aTotalKBytes / 1024).toFixed(1));
}
else if (totalHasMB && !progressHasMB) {
format = this._statusFormatKBMB;
format = this._replaceInsert(format, 1, aKBytes);
format = this._replaceInsert(format, 2, (aTotalKBytes / 1000).toFixed(1));
format = this._replaceInsert(format, 2, (aTotalKBytes / 1024).toFixed(1));
}
else if (progressHasMB && !totalHasMB) {
format = this._statusFormatUnknownMB;
format = this._replaceInsert(format, 1, (aKBytes / 1000).toFixed(1));
else if (progressHasMB && !totalHasMB) {
format = this._statusFormatUnknownMB;
format = this._replaceInsert(format, 1, (aKBytes / 1024).toFixed(1));
}
else {
// This is an undefined state!