(manifest: Manifest, hash: string)
| 1006 | } |
| 1007 | |
| 1008 | private async setupUpdate(manifest: Manifest, hash: string): Promise<void> { |
| 1009 | try { |
| 1010 | const newVersion = new AppVersion( |
| 1011 | this.scope, |
| 1012 | this.adapter, |
| 1013 | this.db, |
| 1014 | this.idle, |
| 1015 | this.debugger, |
| 1016 | manifest, |
| 1017 | hash, |
| 1018 | ); |
| 1019 | |
| 1020 | // Firstly, check if the manifest version is correct. |
| 1021 | if (manifest.configVersion !== SUPPORTED_CONFIG_VERSION) { |
| 1022 | await this.deleteAllCaches(); |
| 1023 | await this.scope.registration.unregister(); |
| 1024 | throw new Error( |
| 1025 | `Invalid config version: expected ${SUPPORTED_CONFIG_VERSION}, got ${manifest.configVersion}.`, |
| 1026 | ); |
| 1027 | } |
| 1028 | |
| 1029 | // Cause the new version to become fully initialized. If this fails, then the |
| 1030 | // version will not be available for use. |
| 1031 | await newVersion.initializeFully(this); |
| 1032 | |
| 1033 | // Install this as an active version of the app. |
| 1034 | this.versions.set(hash, newVersion); |
| 1035 | // Future new clients will use this hash as the latest version. |
| 1036 | this.latestHash = hash; |
| 1037 | |
| 1038 | // If we are in `EXISTING_CLIENTS_ONLY` mode (meaning we didn't have a clean copy of the last |
| 1039 | // latest version), we can now recover to `NORMAL` mode and start accepting new clients. |
| 1040 | if (this.state === DriverReadyState.EXISTING_CLIENTS_ONLY) { |
| 1041 | this.state = DriverReadyState.NORMAL; |
| 1042 | this.stateMessage = '(nominal)'; |
| 1043 | } |
| 1044 | |
| 1045 | await this.sync(); |
| 1046 | await this.notifyClientsAboutVersionReady(manifest, hash); |
| 1047 | } catch (e) { |
| 1048 | await this.notifyClientsAboutVersionInstallationFailed(manifest, hash, e); |
| 1049 | throw e; |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | async checkForUpdate(): Promise<boolean> { |
| 1054 | let hash: string = '(unknown)'; |
no test coverage detected