diff options
author | Moonchild <moonchild@palemoon.org> | 2022-01-07 12:12:46 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-01-07 12:12:46 +0000 |
commit | 9cb21608f1ac1874da7e4ddd9b5f217f3e16fc29 (patch) | |
tree | c64011eb255e8b3fc0a486a636ad9e59f49e6c5a /components | |
parent | 1699dbe78bf43eaa5ef4c593f075dfdc59c02b15 (diff) | |
parent | 811b994a48ba359f8d62aae7771f8aa01186bef4 (diff) | |
download | aura-central-9cb21608f1ac1874da7e4ddd9b5f217f3e16fc29.tar.gz |
Merge branch 'master' into Remove-GMP
Diffstat (limited to 'components')
-rw-r--r-- | components/jsdownloads/src/DownloadCore.jsm | 75 |
1 files changed, 32 insertions, 43 deletions
diff --git a/components/jsdownloads/src/DownloadCore.jsm b/components/jsdownloads/src/DownloadCore.jsm index da1a740fb..007d705f7 100644 --- a/components/jsdownloads/src/DownloadCore.jsm +++ b/components/jsdownloads/src/DownloadCore.jsm @@ -370,12 +370,6 @@ this.Download.prototype = { message: "Cannot start after finalization."})); } - if (this.error && this.error.becauseBlockedByReputationCheck) { - return Promise.reject(new DownloadError({ - message: "Cannot start after being blocked " + - "by a reputation check."})); - } - // Initialize all the status properties for a new or restarted download. this.stopped = false; this.canceled = false; @@ -1533,7 +1527,6 @@ this.DownloadError = function (aProperties) this.message = aProperties.message; } else if (aProperties.becauseBlocked || aProperties.becauseBlockedByParentalControls || - aProperties.becauseBlockedByReputationCheck || aProperties.becauseBlockedByRuntimePermissions) { this.message = "Download blocked."; } else { @@ -1558,10 +1551,6 @@ this.DownloadError = function (aProperties) if (aProperties.becauseBlockedByParentalControls) { this.becauseBlocked = true; this.becauseBlockedByParentalControls = true; - } else if (aProperties.becauseBlockedByReputationCheck) { - this.becauseBlocked = true; - this.becauseBlockedByReputationCheck = true; - this.reputationCheckVerdict = aProperties.reputationCheckVerdict || ""; } else if (aProperties.becauseBlockedByRuntimePermissions) { this.becauseBlocked = true; this.becauseBlockedByRuntimePermissions = true; @@ -1576,16 +1565,6 @@ this.DownloadError = function (aProperties) this.stack = new Error().stack; } -/** - * These constants are used by the reputationCheckVerdict property and indicate - * the detailed reason why a download is blocked. - * - * @note These values should not be changed because they can be serialized. - */ -this.DownloadError.BLOCK_VERDICT_MALWARE = "Malware"; -this.DownloadError.BLOCK_VERDICT_POTENTIALLY_UNWANTED = "PotentiallyUnwanted"; -this.DownloadError.BLOCK_VERDICT_UNCOMMON = "Uncommon"; - this.DownloadError.prototype = { __proto__: Error.prototype, @@ -1617,12 +1596,6 @@ this.DownloadError.prototype = { becauseBlockedByParentalControls: false, /** - * Indicates the download was blocked because it failed the reputation check - * and may be malware. - */ - becauseBlockedByReputationCheck: false, - - /** * Indicates the download was blocked because a runtime permission required to * download files was not granted. * @@ -1631,15 +1604,6 @@ this.DownloadError.prototype = { becauseBlockedByRuntimePermissions: false, /** - * If becauseBlockedByReputationCheck is true, indicates the detailed reason - * why the download was blocked, according to the "BLOCK_VERDICT_" constants. - * - * If the download was not blocked or the reason for the block is unknown, - * this will be an empty string. - */ - reputationCheckVerdict: "", - - /** * If this DownloadError was caused by an exception this property will * contain the original exception. This will not be serialized when saving * to the store. @@ -1660,9 +1624,7 @@ this.DownloadError.prototype = { becauseTargetFailed: this.becauseTargetFailed, becauseBlocked: this.becauseBlocked, becauseBlockedByParentalControls: this.becauseBlockedByParentalControls, - becauseBlockedByReputationCheck: this.becauseBlockedByReputationCheck, becauseBlockedByRuntimePermissions: this.becauseBlockedByRuntimePermissions, - reputationCheckVerdict: this.reputationCheckVerdict, }; serializeUnknownProperties(this, serializable); @@ -1687,9 +1649,7 @@ this.DownloadError.fromSerializable = function (aSerializable) { property != "becauseTargetFailed" && property != "becauseBlocked" && property != "becauseBlockedByParentalControls" && - property != "becauseBlockedByReputationCheck" && - property != "becauseBlockedByRuntimePermissions" && - property != "reputationCheckVerdict"); + property != "becauseBlockedByRuntimePermissions"); return e; }; @@ -1847,7 +1807,7 @@ this.DownloadSaver.fromSerializable = function (aSerializable) { saver = DownloadPDFSaver.fromSerializable(serializable); break; default: - throw new Error("Unrecoginzed download saver type."); + throw new Error("Unrecognized download saver type."); } return saver; }; @@ -2166,7 +2126,8 @@ this.DownloadCopySaver.prototype = { // We will wait on this promise in case no error occurred while setting // up the chain of objects for the download. yield deferSaveComplete.promise; - + + yield this._moveFinalDownload(aSetPropertiesFn); } catch (ex) { // Ensure we always remove the placeholder for the final target file on // failure, independently of which code path failed. In some cases, the @@ -2189,6 +2150,26 @@ this.DownloadCopySaver.prototype = { }, /** + * If the download passes the reputation check and is using a part file we + * will move it to the target path. + * + * @param aSetPropertiesFn + * Function provided to the "execute" method. + * + * @return {Promise} + * @resolves When the cleanup is complete. + */ + _moveFinalDownload: Task.async(function* (aSetPropertiesFn) { + let download = this.download; + let targetPath = this.download.target.path; + let partFilePath = this.download.target.partFilePath; + + if (partFilePath) { + yield OS.File.move(partFilePath, targetPath); + } + }), + + /** * Implements "DownloadSaver.cancel". */ cancel: function DCS_cancel() @@ -2514,6 +2495,9 @@ this.DownloadLegacySaver.prototype = { } } } + + yield this._moveFinalDownload(aSetPropertiesFn); + } catch (ex) { // Ensure we always remove the final target file on failure, // independently of which code path failed. In some cases, the @@ -2546,6 +2530,11 @@ this.DownloadLegacySaver.prototype = { }.bind(this)); }, + _moveFinalDownload: function () { + return DownloadCopySaver.prototype._moveFinalDownload + .apply(this, arguments); + }, + /** * Implements "DownloadSaver.cancel". */ |