summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2022-04-07 18:11:40 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2022-04-07 18:18:52 +0800
commitecbe89cd7d4aef01de3f63033f50968f8cafe158 (patch)
tree16dc58bfd39e0a97e7d6c0ba3cb1b4c5f6b80ca7
parenta7bb2962936592a477c63dffb990c99efbdbcf17 (diff)
downloaduxp-ecbe89cd7d4aef01de3f63033f50968f8cafe158.tar.gz
Issue #1822 - Follow-up: Restore method that moves downloaded data's part file
This commit fixes the issue where all downloaded files are empty/zero-byte by creating a new `_move` method, which is called in place of the removed `_checkReputationAndMove` method. In 6042fdd44c0ec532b3e33d4f4046826fa1548d13 the reputation check for downloads was removed but that same method is also being used for moving the part file of completed downloads, which consequently broke all downloads except those without a part file, and made them empty since the actual downloaded file isn't being moved.
-rw-r--r--toolkit/components/jsdownloads/src/DownloadCore.jsm25
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".
*/