diff options
author | Moonchild <moonchild@palemoon.org> | 2022-04-07 10:37:33 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-04-07 10:37:33 +0000 |
commit | 429a4cd9d7b9683df3a041ecc9edad12230165bc (patch) | |
tree | 16dc58bfd39e0a97e7d6c0ba3cb1b4c5f6b80ca7 | |
parent | a7bb2962936592a477c63dffb990c99efbdbcf17 (diff) | |
parent | ecbe89cd7d4aef01de3f63033f50968f8cafe158 (diff) | |
download | uxp-429a4cd9d7b9683df3a041ecc9edad12230165bc.tar.gz |
Merge pull request 'Restore method that moves downloaded data's part file' (#1848) from FranklinDM/UXP-contrib:work_safebrowsing-removal-followup into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1848
-rw-r--r-- | toolkit/components/jsdownloads/src/DownloadCore.jsm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/toolkit/components/jsdownloads/src/DownloadCore.jsm b/toolkit/components/jsdownloads/src/DownloadCore.jsm index da1a740fb7..4be4911a66 100644 --- a/toolkit/components/jsdownloads/src/DownloadCore.jsm +++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm @@ -2167,6 +2167,7 @@ this.DownloadCopySaver.prototype = { // up the chain of objects for the download. yield deferSaveComplete.promise; + yield this._move(); } 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 +2190,23 @@ this.DownloadCopySaver.prototype = { }, /** + * Move the downloaded data if required. + * If the download is using a part file we will move it to the target path + * since this is the final step in the saver. + * + * @return {Promise} + * @resolves When the move is complete. + */ + _move: Task.async(function* () { + 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 +2532,8 @@ this.DownloadLegacySaver.prototype = { } } } + + yield this._move(); } catch (ex) { // Ensure we always remove the final target file on failure, // independently of which code path failed. In some cases, the @@ -2546,6 +2566,11 @@ this.DownloadLegacySaver.prototype = { }.bind(this)); }, + _move: function () { + return DownloadCopySaver.prototype._move + .apply(this, arguments); + }, + /** * Implements "DownloadSaver.cancel". */ |