From beeede618586155d0f3fcb8e9313e076eef3e6e5 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Sun, 29 Jul 2018 12:41:33 +0200 Subject: [PALEMOON] Bug 1127867 - Use the new back-end property to get the size of downloads asynchronously --- .../downloads/content/downloadsViewCommon.js | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'application/palemoon/components/downloads/content/downloadsViewCommon.js') diff --git a/application/palemoon/components/downloads/content/downloadsViewCommon.js b/application/palemoon/components/downloads/content/downloadsViewCommon.js index 999d82317..7ae3eb850 100644 --- a/application/palemoon/components/downloads/content/downloadsViewCommon.js +++ b/application/palemoon/components/downloads/content/downloadsViewCommon.js @@ -142,6 +142,15 @@ DownloadElementShell.prototype = { * namely the progress bar and the status line. */ _updateProgress() { + if (this.download.succeeded) { + // We only need to add or remove this attribute for succeeded downloads. + if (this.download.target.exists) { + this.element.setAttribute("exists", "true"); + } else { + this.element.removeAttribute("exists"); + } + } + // The progress bar is only displayed for in-progress downloads. if (this.download.hasProgress) { this.element.setAttribute("progressmode", "normal"); @@ -182,26 +191,26 @@ DownloadElementShell.prototype = { let tip = ""; if (!this.download.stopped) { - let maxBytes = DownloadsCommon.maxBytesOfDownload(this.download); + let total = this.download.hasProgress ? this.download.totalBytes : -1; // By default, extended status information including the individual // download rate is displayed in the tooltip. The history view overrides // the getter and displays the detials in the main area instead. [text] = DownloadUtils.getDownloadStatusNoRate( this.download.currentBytes, - maxBytes, + total, this.download.speed, this.lastEstimatedSecondsLeft); let newEstimatedSecondsLeft; [tip, newEstimatedSecondsLeft] = DownloadUtils.getDownloadStatus( this.download.currentBytes, - maxBytes, + total, this.download.speed, this.lastEstimatedSecondsLeft); this.lastEstimatedSecondsLeft = newEstimatedSecondsLeft; } else if (this.download.canceled && this.download.hasPartialData) { - let maxBytes = DownloadsCommon.maxBytesOfDownload(this.download); + let total = this.download.hasProgress ? this.download.totalBytes : -1; let transfer = DownloadUtils.getTransferTotal(this.download.currentBytes, - maxBytes); + total); // We use the same XUL label to display both the state and the amount // transferred, for example "Paused - 1.1 MB". @@ -213,12 +222,13 @@ DownloadElementShell.prototype = { let stateLabel; if (this.download.succeeded) { - // For completed downloads, show the file size (e.g. "1.5 MB") - let maxBytes = DownloadsCommon.maxBytesOfDownload(this.download); - if (maxBytes >= 0) { - let [size, unit] = DownloadUtils.convertByteUnits(maxBytes); + // For completed downloads, show the file size (e.g. "1.5 MB"). + if (this.download.target.size !== undefined) { + let [size, unit] = DownloadUtils.convertByteUnits( + this.download.target.size); stateLabel = s.sizeWithUnits(size, unit); } else { + // History downloads may not have a size defined. stateLabel = s.sizeUnknown; } } else if (this.download.canceled) { -- cgit v1.2.3