From a84749d37634584ae7c5cdc5f0ab8200cc9c8b81 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Sat, 6 Mar 2021 17:27:40 +0100 Subject: [PATCH 1/5] fix packaged asar path --- src/core/helpers/asarLibs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/helpers/asarLibs.js b/src/core/helpers/asarLibs.js index f992ca5e..345cbc4c 100644 --- a/src/core/helpers/asarLibs.js +++ b/src/core/helpers/asarLibs.js @@ -29,7 +29,7 @@ const packageInfo = require("../../../package.json"); */ function asarLibPathHack(lib) { return packageInfo.package - ? path.join(__dirname, "../../../app.asar.unpacked/node_modules/", lib) + ? path.join(__dirname, "../../../../app.asar.unpacked/node_modules/", lib) : lib; } From a037b16d00f4c579ab0a4dfaf7a44450e0ea5a79 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Sat, 6 Mar 2021 17:28:38 +0100 Subject: [PATCH 2/5] Add jsdoc for core:manual_download --- src/core/plugins/core/plugin.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/plugins/core/plugin.js b/src/core/plugins/core/plugin.js index 51c5f652..caef68c8 100644 --- a/src/core/plugins/core/plugin.js +++ b/src/core/plugins/core/plugin.js @@ -208,6 +208,11 @@ class CorePlugin extends Plugin { ); } + /** + * core:manual_download action + * @param {Object} param0 {group, file} + * @returns {Promise} + */ action__manual_download({ group, file }) { return Promise.resolve() .then(() => { From 31f18b8eff3dcbbeca1b2f43a0691f494f149230 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Sat, 6 Mar 2021 17:29:19 +0100 Subject: [PATCH 3/5] typo --- src/core/plugins/core/plugin.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/plugins/core/plugin.spec.js b/src/core/plugins/core/plugin.spec.js index 9dc3631d..85a84623 100644 --- a/src/core/plugins/core/plugin.spec.js +++ b/src/core/plugins/core/plugin.spec.js @@ -143,7 +143,7 @@ describe("core plugin", () => { download.mockRejectedValueOnce("download error"); core .action__download({ - group: "fimrware", + group: "firmware", files: [ { url: "a/c", checksum: { sum: "b", algorithm: "sha256" } }, { url: "a/b", checksum: { sum: "a", algorithm: "sha256" } } From e08a39e3f267f392fcd00c3dff9532560288a220 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Sat, 6 Mar 2021 17:29:59 +0100 Subject: [PATCH 4/5] Allow renaming downloaded files, resolves #1611 --- src/core/plugins/core/plugin.js | 5 ++-- src/core/plugins/core/plugin.spec.js | 35 ++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/core/plugins/core/plugin.js b/src/core/plugins/core/plugin.js index caef68c8..5c16ef8a 100644 --- a/src/core/plugins/core/plugin.js +++ b/src/core/plugins/core/plugin.js @@ -121,7 +121,7 @@ class CorePlugin extends Plugin { this.cachePath, this.props.config.codename, group, - path.basename(file.url) + file.name || path.basename(file.url) ) })), (progress, speed) => { @@ -130,8 +130,9 @@ class CorePlugin extends Plugin { this.event.emit("user:write:under", "Downloading"); }, (current, total) => { - if (current > 1) + if (current > 0) this.log.info(`Downloaded file ${current} of ${total}`); + else this.log.info(`Downloading ${total} files`); this.event.emit( "user:write:status", `${current} of ${total} files downloaded and verified`, diff --git a/src/core/plugins/core/plugin.spec.js b/src/core/plugins/core/plugin.spec.js index 85a84623..5aa9e308 100644 --- a/src/core/plugins/core/plugin.spec.js +++ b/src/core/plugins/core/plugin.spec.js @@ -132,13 +132,34 @@ describe("core plugin", () => { describe("action__download()", () => { it("should download", () => - core.action__download({ - group: "fimrware", - files: [ - { url: "a/c", checksum: { sum: "b", algorithm: "sha256" } }, - { url: "a/b", checksum: { sum: "a", algorithm: "sha256" } } - ] - })); // TODO add assertions for event messages + core + .action__download({ + group: "firmware", + files: [ + { url: "a/c", checksum: { sum: "b", algorithm: "sha256" } }, + { url: "a/b" }, + { url: "a/c", name: "d" } + ] + }) + .then(r => { + expect(r).toEqual(undefined); + expect(download).toHaveBeenCalledTimes(1); + expect(download).toHaveBeenCalledWith( + [ + { + checksum: { algorithm: "sha256", sum: "b" }, + path: "a/yggdrasil/firmware/c", + url: "a/c" + }, + { path: "a/yggdrasil/firmware/b", url: "a/b" }, + { name: "d", path: "a/yggdrasil/firmware/d", url: "a/c" } + ], + expect.any(Function), + expect.any(Function), + expect.any(Function) + ); + expect(mainEvent.emit).toHaveBeenCalledTimes(20); + })); it("should show network error", done => { download.mockRejectedValueOnce("download error"); core From ea3958145fae94f6c5a56ade8821945236829792 Mon Sep 17 00:00:00 2001 From: Jan Sprinz Date: Sat, 6 Mar 2021 17:40:18 +0100 Subject: [PATCH 5/5] Fix windows test --- src/core/plugins/core/plugin.spec.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/plugins/core/plugin.spec.js b/src/core/plugins/core/plugin.spec.js index 5aa9e308..f3cda43a 100644 --- a/src/core/plugins/core/plugin.spec.js +++ b/src/core/plugins/core/plugin.spec.js @@ -148,11 +148,18 @@ describe("core plugin", () => { [ { checksum: { algorithm: "sha256", sum: "b" }, - path: "a/yggdrasil/firmware/c", + path: expect.stringMatching(/a.yggdrasil.firmware.c/), url: "a/c" }, - { path: "a/yggdrasil/firmware/b", url: "a/b" }, - { name: "d", path: "a/yggdrasil/firmware/d", url: "a/c" } + { + path: expect.stringMatching(/a.yggdrasil.firmware.b/), + url: "a/b" + }, + { + name: "d", + path: expect.stringMatching(/a.yggdrasil.firmware.d/), + url: "a/c" + } ], expect.any(Function), expect.any(Function),