MCPcopy
hub / github.com/angular/angular / checkForUpdate

Method checkForUpdate

packages/service-worker/worker/src/driver.ts:1053–1086  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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.

Callers 5

handleMessageMethod · 0.95
handleFetchMethod · 0.95
initializeMethod · 0.95
happy_spec.tsFile · 0.45
data_spec.tsFile · 0.45

Calls 8

fetchLatestManifestMethod · 0.95
setupUpdateMethod · 0.95
hashManifestFunction · 0.90
errorToStringFunction · 0.90
logMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected