From b1376dfa73fe9f450c0c0d3be33d7912ef991a52 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Wed, 10 Jun 2020 12:27:37 +0200 Subject: [PATCH 1/3] Update etcher-sdk to ^4.1.13 Changelog-entry: Update etcher-sdk to ^4.1.13 Change-type: patch --- npm-shrinkwrap.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a970382b..d817f6a6 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -5355,9 +5355,9 @@ "dev": true }, "etcher-sdk": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/etcher-sdk/-/etcher-sdk-4.1.8.tgz", - "integrity": "sha512-fSNwpqeCdc75xNIKwf+At8+r/EQ+/X/IV7gUYFa/wKXtnFHHxYJor6VfPdELUbtDDBWWa2cneJvtwGmcDPBAvA==", + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/etcher-sdk/-/etcher-sdk-4.1.13.tgz", + "integrity": "sha512-ITzBgoy8AGI6/DHyS43wix2TNa9kVeILsr/vQl75Hbbt5gM4C2ygwqABG7V+MGTaNphWc2OstSP9k6xQpGfttw==", "dev": true, "requires": { "@ronomon/direct-io": "^3.0.1", @@ -15060,4 +15060,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 61e2bfd7..a62a862d 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "electron-notarize": "^0.3.0", "electron-rebuild": "^1.11.0", "electron-updater": "^4.3.2", - "etcher-sdk": "^4.1.8", + "etcher-sdk": "^4.1.13", "file-loader": "^6.0.0", "flexboxgrid": "^6.3.0", "husky": "^4.2.5", From 52bdd02a4b7b17e5821f96faa04d2c280d7e27c9 Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Wed, 10 Jun 2020 14:48:44 +0200 Subject: [PATCH 2/3] Check that argument is an url or a regular file before opening Changelog-entry: Check that argument is an url or a regular file before opening Change-type: patch --- lib/gui/etcher.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/gui/etcher.ts b/lib/gui/etcher.ts index 76cf50b5..afb7842a 100644 --- a/lib/gui/etcher.ts +++ b/lib/gui/etcher.ts @@ -17,6 +17,7 @@ import { delay } from 'bluebird'; import * as electron from 'electron'; import { autoUpdater } from 'electron-updater'; +import { promises as fs } from 'fs'; import { platform } from 'os'; import * as _ from 'lodash'; import * as path from 'path'; @@ -57,7 +58,17 @@ async function checkForUpdates(interval: number) { } } -function getCommandLineURL(argv: string[]): string | undefined { +async function isFile(filePath: string): Promise { + try { + const stat = await fs.stat(filePath); + return stat.isFile(); + } catch { + // noop + } + return false; +} + +async function getCommandLineURL(argv: string[]): Promise { argv = argv.slice(electron.app.isPackaged ? 1 : 2); if (argv.length) { const value = argv[argv.length - 1]; @@ -69,6 +80,14 @@ function getCommandLineURL(argv: string[]): string | undefined { if (platform() === 'darwin' && value.startsWith('-psn_')) { return; } + if ( + !value.startsWith('http://') && + !value.startsWith('https://') && + !value.startsWith(scheme) && + !(await isFile(value)) + ) { + return; + } return value; } } @@ -204,9 +223,9 @@ async function main(): Promise { window.restore(); } window.focus(); - await selectImageURL(getCommandLineURL(argv)); + await selectImageURL(await getCommandLineURL(argv)); }); - await selectImageURL(getCommandLineURL(process.argv)); + await selectImageURL(await getCommandLineURL(process.argv)); } } From 59e37182be060c008f5801cfc1eef7a5ee32224c Mon Sep 17 00:00:00 2001 From: Alexis Svinartchouk Date: Wed, 10 Jun 2020 14:52:04 +0200 Subject: [PATCH 3/3] Use between 2 and 256MiB for buffering depending on the number of drives Changelog-entry: Use between 2 and 256MiB for buffering depending on the number of drives Change-type: patch --- lib/gui/modules/child-writer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gui/modules/child-writer.ts b/lib/gui/modules/child-writer.ts index 108932e8..4cd5e2f9 100644 --- a/lib/gui/modules/child-writer.ts +++ b/lib/gui/modules/child-writer.ts @@ -119,7 +119,7 @@ async function writeAndValidate({ onProgress, verify, trim: autoBlockmapping, - numBuffers: 32, + numBuffers: Math.min(2 + (destinations.length - 1) * 32, 256), decompressFirst, }); const result: WriteResult = {