summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-03-27 14:58:19 +0100
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-05-28 10:28:14 +0200
commitf7c9107cc343b767f7f12522f819eafac9dbe925 (patch)
tree533747d91564823e168b15aaf66af393c426fa66
parent764af9f7a4645332ad9ab435cf679716e47b8c5c (diff)
downloadmullvadvpn-f7c9107cc343b767f7f12522f819eafac9dbe925.tar.xz
mullvadvpn-f7c9107cc343b767f7f12522f819eafac9dbe925.zip
Add ability to start installer
-rw-r--r--desktop/packages/mullvad-vpn/src/main/app-upgrade.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/desktop/packages/mullvad-vpn/src/main/app-upgrade.ts b/desktop/packages/mullvad-vpn/src/main/app-upgrade.ts
index c4e2c3a2aa..a68c80f142 100644
--- a/desktop/packages/mullvad-vpn/src/main/app-upgrade.ts
+++ b/desktop/packages/mullvad-vpn/src/main/app-upgrade.ts
@@ -1,8 +1,14 @@
+import { execFile } from 'child_process';
+import fs from 'fs/promises';
+import { promisify } from 'util';
+
import { DaemonAppUpgradeEvent } from '../shared/daemon-rpc-types';
import log from '../shared/logging';
import { DaemonRpc, SubscriptionListener } from './daemon-rpc';
import { IpcMainEventChannel } from './ipc-event-channel';
+const execFilePromise = promisify(execFile);
+
export default class AppUpgrade {
public constructor(private daemonRpc: DaemonRpc) {}
@@ -14,6 +20,17 @@ export default class AppUpgrade {
IpcMainEventChannel.app.handleUpgradeAbort(() => {
this.daemonRpc.appUpgradeAbort();
});
+
+ IpcMainEventChannel.app.handleUpgradeInstallerStart(async (verifiedInstallerPath: string) => {
+ try {
+ await this.startInstaller(verifiedInstallerPath);
+ IpcMainEventChannel.app.notifyUpgradeEvent?.({
+ type: 'APP_UPGRADE_STATUS_STARTED_INSTALLER',
+ });
+ } catch {
+ IpcMainEventChannel.app.notifyUpgradeError?.('START_INSTALLER_FAILED');
+ }
+ });
}
public subscribeEvents() {
@@ -34,4 +51,25 @@ export default class AppUpgrade {
return daemonAppUpgradeEventListener;
}
+
+ private async startInstaller(verifiedInstallerPath: string) {
+ await this.isInstallerExecutable(verifiedInstallerPath);
+ await this.executeInstaller(verifiedInstallerPath);
+ }
+
+ private async executeInstaller(verifiedInstallerPath: string) {
+ try {
+ await execFilePromise(verifiedInstallerPath);
+ } catch {
+ throw new Error(`Could not start installer at path: ${verifiedInstallerPath}`);
+ }
+ }
+
+ private async isInstallerExecutable(verifiedInstallerPath: string) {
+ try {
+ await fs.access(verifiedInstallerPath, fs.constants.X_OK);
+ } catch {
+ throw new Error(`An executable installer is not available at path: ${verifiedInstallerPath}`);
+ }
+ }
}