()
| 1051 | } |
| 1052 | |
| 1053 | async checkForUpdate(): Promise<boolean> { |
| 1054 | let hash: string = '(unknown)'; |
| 1055 | try { |
| 1056 | const manifest = await this.fetchLatestManifest(true); |
| 1057 | |
| 1058 | if (manifest === null) { |
| 1059 | // Client or server offline. Unable to check for updates at this time. |
| 1060 | // Continue to service clients (existing and new). |
| 1061 | this.debugger.log('Check for update aborted. (Client or server offline.)'); |
| 1062 | return false; |
| 1063 | } |
| 1064 | |
| 1065 | hash = hashManifest(manifest); |
| 1066 | |
| 1067 | // Check whether this is really an update. |
| 1068 | if (this.versions.has(hash)) { |
| 1069 | await this.notifyClientsAboutNoNewVersionDetected(manifest, hash); |
| 1070 | return false; |
| 1071 | } |
| 1072 | |
| 1073 | await this.notifyClientsAboutVersionDetected(manifest, hash); |
| 1074 | |
| 1075 | await this.setupUpdate(manifest, hash); |
| 1076 | |
| 1077 | return true; |
| 1078 | } catch (err) { |
| 1079 | this.debugger.log(err as Error, `Error occurred while updating to manifest ${hash}`); |
| 1080 | |
| 1081 | this.state = DriverReadyState.EXISTING_CLIENTS_ONLY; |
| 1082 | this.stateMessage = `Degraded due to failed initialization: ${errorToString(err)}`; |
| 1083 | |
| 1084 | return false; |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | /** |
| 1089 | * Synchronize the existing state to the underlying database. |
no test coverage detected