Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): .deb updates install after the app was relaunched by an update #35422

Openjuliusmarmingewants to merge 2 commits intomain fromrefs/pull/35422/headopened View on GitHub

Showing 6 changed files with 84 additions and 14 deletions (loading 3).

x
0 of 6 viewed, 6 left
23 additions and 2 deletionsapps/desktop/src/electron/ElectronApp.tsModified
View file
@@ -1,3 +1,6 @@
+// @effect-diagnostics nodeBuiltinImport:off -- Linux relaunch must spawn outside Chromium's launcher.
+import * as NodeChildProcess from "node:child_process";
+​
import * as HostProcess from "@t3tools/shared/HostProcess";
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
@@ -173,9 +176,27 @@
Electron.app.exit(code);
});
}),
- relaunch: Effect.fn("ElectronApp.relaunch")(function (options) {
- return Effect.sync(() => {
+ relaunch: Effect.fn("ElectronApp.relaunch")(function* (options) {
+ if ((yield* HostProcess.Platform) !== "linux") {
Electron.app.relaunch(options);
+ return;
+ }
+ // Electron's Linux relauncher sets irreversible no_new_privs, so pkexec fails in the new app.
+ // The shell waits for EOF on stdin, which comes when this process exits and frees its lock.
+ const execPath = options.execPath ?? (yield* HostProcess.ExecutablePath);
+ const args = options.args ?? (yield* HostProcess.Arguments).slice(1);
+ yield* Effect.sync(() => {
+ try {
+ NodeChildProcess.spawn(
+ "/bin/sh",
+ ["-c", 'cat >/dev/null; exec "$@" </dev/null', "t3code-relaunch", execPath, ...args],
+ { detached: true, stdio: ["pipe", "ignore", "ignore"] },
+ )
+ .on("error", () => Electron.app.relaunch(options))