зеркало из https://github.com/mozilla/pjs.git
Bug 260741 Wrong download file size in MB is reported
p=gavin.sharp@gmail.com r=mconnor
This commit is contained in:
Родитель
20d9b63938
Коммит
5f4c16fd3d
|
@ -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!
|
||||
|
|
Загрузка…
Ссылка в новой задаче