diff --git a/desktop/packages/mullvad-vpn/src/main/index.ts b/desktop/packages/mullvad-vpn/src/main/index.ts index c9067c78e218..57984b6092de 100644 --- a/desktop/packages/mullvad-vpn/src/main/index.ts +++ b/desktop/packages/mullvad-vpn/src/main/index.ts @@ -324,7 +324,7 @@ class ApplicationMain }; private onBeforeQuit = async (event: Electron.Event) => { - if (this.tunnelState.hasReceivedFullDiskAccessError) { + if (this.tunnelState.needFullDiskAccess) { await this.daemonRpc.prepareRestart(true); } @@ -832,8 +832,10 @@ class ApplicationMain splitTunneling!.removeApplicationFromCache(application); return Promise.resolve(); }); - IpcMainEventChannel.macOsSplitTunneling.handleNeedFullDiskPermissions(() => { - return this.daemonRpc.needFullDiskPermissions(); + IpcMainEventChannel.macOsSplitTunneling.handleNeedFullDiskPermissions(async () => { + const fullDiskState = await this.daemonRpc.needFullDiskPermissions(); + this.tunnelState.needFullDiskAccess = fullDiskState; + return fullDiskState; }); IpcMainEventChannel.app.handleQuit(() => this.disconnectAndQuit()); diff --git a/desktop/packages/mullvad-vpn/src/main/tunnel-state.ts b/desktop/packages/mullvad-vpn/src/main/tunnel-state.ts index 43ebe97ad6a8..b83b88a0f8ba 100644 --- a/desktop/packages/mullvad-vpn/src/main/tunnel-state.ts +++ b/desktop/packages/mullvad-vpn/src/main/tunnel-state.ts @@ -11,6 +11,8 @@ export interface TunnelStateHandlerDelegate { } export default class TunnelStateHandler { + public needFullDiskAccess = false; + // The current tunnel state private tunnelStateValue: TunnelState = { state: 'disconnected' }; // When pressing connect/disconnect/reconnect the app assumes what the next state will be before @@ -20,15 +22,10 @@ export default class TunnelStateHandler { // Scheduler for discarding the assumed next state. private tunnelStateFallbackScheduler = new Scheduler(); - private receivedFullDiskAccessError = false; - private lastKnownDisconnectedLocation: Partial | undefined; public constructor(private delegate: TunnelStateHandlerDelegate) {} - public get hasReceivedFullDiskAccessError() { - return this.receivedFullDiskAccessError; - } public get tunnelState() { return this.tunnelStateValue; } @@ -60,7 +57,7 @@ export default class TunnelStateHandler { public handleNewTunnelState(newState: TunnelState) { if (newState.state === 'error' && newState.details) { if (newState.details.cause === ErrorStateCause.needFullDiskPermissions) { - this.receivedFullDiskAccessError = true; + this.needFullDiskAccess = true; } }