MCPcopy
hub / github.com/angular/angular / sync

Method sync

packages/service-worker/worker/src/driver.ts:1091–1118  ·  view source on GitHub ↗

* Synchronize the existing state to the underlying database.

()

Source from the content-addressed store, hash-verified

1089 * Synchronize the existing state to the underlying database.
1090 */
1091 private async sync(): Promise<void> {
1092 const table = await this.controlTable;
1093
1094 // Construct a serializable map of hashes to manifests.
1095 const manifests: ManifestMap = {};
1096 this.versions.forEach((version, hash) => {
1097 manifests[hash] = version.manifest;
1098 });
1099
1100 // Construct a serializable map of client ids to version hashes.
1101 const assignments: ClientAssignments = {};
1102 this.clientVersionMap.forEach((hash, clientId) => {
1103 assignments[clientId] = hash;
1104 });
1105
1106 // Record the latest entry. Since this is a sync which is necessarily happening after
1107 // initialization, latestHash should always be valid.
1108 const latest: LatestEntry = {
1109 latest: this.latestHash!,
1110 };
1111
1112 // Synchronize all of these.
1113 await Promise.all([
1114 table.write('manifests', manifests),
1115 table.write('assignments', assignments),
1116 table.write('latest', latest),
1117 ]);
1118 }
1119
1120 async cleanupCaches(): Promise<void> {
1121 try {

Callers 4

updateClientMethod · 0.95
assignVersionMethod · 0.95
setupUpdateMethod · 0.95
cleanupCachesMethod · 0.95

Calls 3

writeMethod · 0.65
forEachMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected