diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-04-07 15:29:43 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-04-07 15:29:43 +0200 |
| commit | 74ec2b59d1fa20604973f1bd4e5cd503631c2365 (patch) | |
| tree | 3fa5771c1ad09e055086dab16c273c2b44d756bf /gui/src/main | |
| parent | 3640e7731c8855de871c7d1af97a8d07414a4913 (diff) | |
| parent | a64c38052e9cf316d2819adcee89802f747dd630 (diff) | |
| download | mullvadvpn-74ec2b59d1fa20604973f1bd4e5cd503631c2365.tar.xz mullvadvpn-74ec2b59d1fa20604973f1bd4e5cd503631c2365.zip | |
Merge branch 'handle-post-upgrade-flag'
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 5 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 29 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index b3add4ec1d..52c43441a6 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -499,6 +499,11 @@ export class DaemonRpc { await this.callEmpty(this.client.checkVolumes); } + public async isPerformingPostUpgrade(): Promise<boolean> { + const response = await this.callEmpty<BoolValue>(this.client.isPerformingPostUpgrade); + return response.getValue(); + } + public async getDevice(): Promise<IDeviceConfig | undefined> { try { const response = await this.callEmpty<grpcTypes.DeviceConfig>(this.client.getDevice); diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index e36c8d1b70..1dfde6537d 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -128,6 +128,7 @@ class ApplicationMain { private reconnectBackoff = new ReconnectionBackoff(); private beforeFirstDaemonConnection = true; private connectedToDaemon = false; + private isPerformingPostUpgrade = false; private quitStage = AppQuitStage.unready; private accountData?: IAccountData = undefined; @@ -626,6 +627,18 @@ class ApplicationMain { return this.handleBootstrapError(error); } + if (firstDaemonConnection) { + // check if daemon is performing post upgrade tasks the first time it's connected to + try { + await this.performPostUpgradeCheck(); + } catch (e) { + const error = e as Error; + log.error(`Failed to check if daemon is performing post upgrade tasks: ${error.message}`); + + return this.handleBootstrapError(error); + } + } + // fetch account history try { this.setAccountHistory(await this.daemonRpc.getAccountHistory()); @@ -808,6 +821,17 @@ class ApplicationMain { return daemonEventListener; } + private async performPostUpgradeCheck(): Promise<void> { + const oldValue = this.isPerformingPostUpgrade; + this.isPerformingPostUpgrade = await this.daemonRpc.isPerformingPostUpgrade(); + if (this.windowController && this.isPerformingPostUpgrade !== oldValue) { + IpcMainEventChannel.daemon.notifyIsPerformingPostUpgrade( + this.windowController.webContents, + this.isPerformingPostUpgrade, + ); + } + } + private connectTunnel = async (): Promise<void> => { if ( connectEnabled( @@ -1125,6 +1149,10 @@ class ApplicationMain { this.deviceConfig = deviceEvent.deviceConfig; this.hasReceivedDeviceConfig = true; + if (this.isPerformingPostUpgrade) { + void this.performPostUpgradeCheck(); + } + // make sure to invalidate the account data cache when account tokens change this.updateAccountDataOnAccountChange( oldDeviceConfig?.accountToken, @@ -1219,6 +1247,7 @@ class ApplicationMain { accountHistory: this.accountHistory, tunnelState: this.tunnelState, settings: this.settings, + isPerformingPostUpgrade: this.isPerformingPostUpgrade, deviceConfig: this.deviceConfig, hasReceivedDeviceConfig: this.hasReceivedDeviceConfig, relayListPair: { |
