From c5a72f616a158d4f6cd807341e0090c5e342876b Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Fri, 22 Nov 2024 20:57:19 -0500 Subject: [PATCH 1/3] use renameSync instead of mv --- packages/electron-updater/src/AppImageUpdater.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/electron-updater/src/AppImageUpdater.ts b/packages/electron-updater/src/AppImageUpdater.ts index a498ac13bee..27e5430362c 100644 --- a/packages/electron-updater/src/AppImageUpdater.ts +++ b/packages/electron-updater/src/AppImageUpdater.ts @@ -1,7 +1,7 @@ import { AllPublishOptions, newError } from "builder-util-runtime" import { execFileSync } from "child_process" import { chmod } from "fs-extra" -import { unlinkSync } from "fs" +import { unlinkSync, renameSync } from "fs" import * as path from "path" import { DownloadUpdateOptions } from "./AppUpdater" import { BaseUpdater, InstallOptions } from "./BaseUpdater" @@ -93,7 +93,7 @@ export class AppImageUpdater extends BaseUpdater { destination = path.join(path.dirname(appImageFile), path.basename(options.installerPath)) } - execFileSync("mv", ["-f", options.installerPath, destination]) + renameSync(options.installerPath, destination) if (destination !== appImageFile) { this.emit("appimage-filename-updated", destination) } From d79023042f2cc2b5b1cc22ba9b0c71ee2d2ea43a Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Fri, 22 Nov 2024 21:03:35 -0500 Subject: [PATCH 2/3] add changeset --- .changeset/olive-chicken-build.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/olive-chicken-build.md diff --git a/.changeset/olive-chicken-build.md b/.changeset/olive-chicken-build.md new file mode 100644 index 00000000000..8119ded4ae9 --- /dev/null +++ b/.changeset/olive-chicken-build.md @@ -0,0 +1,5 @@ +--- +"electron-updater": patch +--- + +fix: use renameSync instead of mv From 43213ef05a4fe7de5e6bbf4133bde8fb681b77c8 Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Mon, 25 Nov 2024 08:01:30 -0500 Subject: [PATCH 3/3] delete bash --- packages/electron-updater/src/BaseUpdater.ts | 12 +----------- packages/electron-updater/src/DebUpdater.ts | 4 +--- packages/electron-updater/src/PacmanUpdater.ts | 4 +--- packages/electron-updater/src/RpmUpdater.ts | 4 +--- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/electron-updater/src/BaseUpdater.ts b/packages/electron-updater/src/BaseUpdater.ts index 2109058415c..4851435ced0 100644 --- a/packages/electron-updater/src/BaseUpdater.ts +++ b/packages/electron-updater/src/BaseUpdater.ts @@ -48,17 +48,7 @@ export abstract class BaseUpdater extends AppUpdater { } const downloadedUpdateHelper = this.downloadedUpdateHelper - - // Get the installer path, ensuring spaces are escaped on Linux - // 1. Check if downloadedUpdateHelper is not null - // 2. Check if downloadedUpdateHelper.file is not null - // 3. If both checks pass: - // a. If the platform is Linux, replace spaces with '\ ' for shell compatibility - // b. If the platform is not Linux, use the original path - // 4. If any check fails, set installerPath to null - const installerPath = - downloadedUpdateHelper && downloadedUpdateHelper.file ? (process.platform === "linux" ? downloadedUpdateHelper.file.replace(/ /g, "\\ ") : downloadedUpdateHelper.file) : null - + const installerPath = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.file const downloadedFileInfo = downloadedUpdateHelper == null ? null : downloadedUpdateHelper.downloadedFileInfo if (installerPath == null || downloadedFileInfo == null) { this.dispatchError(new Error("No valid update available, can't quit and install")) diff --git a/packages/electron-updater/src/DebUpdater.ts b/packages/electron-updater/src/DebUpdater.ts index 52e618dae87..85508f03bee 100644 --- a/packages/electron-updater/src/DebUpdater.ts +++ b/packages/electron-updater/src/DebUpdater.ts @@ -29,10 +29,8 @@ export class DebUpdater extends BaseUpdater { protected doInstall(options: InstallOptions): boolean { const sudo = this.wrapSudo() - // pkexec doesn't want the command to be wrapped in " quotes - const wrapper = /pkexec/i.test(sudo) ? "" : `"` const cmd = ["dpkg", "-i", options.installerPath, "||", "apt-get", "install", "-f", "-y"] - this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]) + this.spawnSyncLog(sudo, cmd) if (options.isForceRunAfter) { this.app.relaunch() } diff --git a/packages/electron-updater/src/PacmanUpdater.ts b/packages/electron-updater/src/PacmanUpdater.ts index 61c9b9e8406..d4ba138903b 100644 --- a/packages/electron-updater/src/PacmanUpdater.ts +++ b/packages/electron-updater/src/PacmanUpdater.ts @@ -29,10 +29,8 @@ export class PacmanUpdater extends BaseUpdater { protected doInstall(options: InstallOptions): boolean { const sudo = this.wrapSudo() - // pkexec doesn't want the command to be wrapped in " quotes - const wrapper = /pkexec/i.test(sudo) ? "" : `"` const cmd = ["pacman", "-U", "--noconfirm", options.installerPath] - this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]) + this.spawnSyncLog(sudo, cmd) if (options.isForceRunAfter) { this.app.relaunch() } diff --git a/packages/electron-updater/src/RpmUpdater.ts b/packages/electron-updater/src/RpmUpdater.ts index 035a92c25cd..4f37f0f8475 100644 --- a/packages/electron-updater/src/RpmUpdater.ts +++ b/packages/electron-updater/src/RpmUpdater.ts @@ -30,8 +30,6 @@ export class RpmUpdater extends BaseUpdater { protected doInstall(options: InstallOptions): boolean { const upgradePath = options.installerPath const sudo = this.wrapSudo() - // pkexec doesn't want the command to be wrapped in " quotes - const wrapper = /pkexec/i.test(sudo) ? "" : `"` const packageManager = this.spawnSyncLog("which zypper") let cmd: string[] if (!packageManager) { @@ -40,7 +38,7 @@ export class RpmUpdater extends BaseUpdater { } else { cmd = [packageManager, "--no-refresh", "install", "--allow-unsigned-rpm", "-y", "-f", upgradePath] } - this.spawnSyncLog(sudo, [`${wrapper}/bin/bash`, "-c", `'${cmd.join(" ")}'${wrapper}`]) + this.spawnSyncLog(sudo, cmd) if (options.isForceRunAfter) { this.app.relaunch() }