(client: Client)
| 548 | } |
| 549 | |
| 550 | async updateClient(client: Client): Promise<boolean> { |
| 551 | // Figure out which version the client is on. If it's not on the latest, |
| 552 | // it needs to be moved. |
| 553 | const existing = this.clientVersionMap.get(client.id); |
| 554 | if (existing === this.latestHash) { |
| 555 | // Nothing to do, this client is already on the latest version. |
| 556 | return false; |
| 557 | } |
| 558 | |
| 559 | // Switch the client over. |
| 560 | let previous: Object | undefined = undefined; |
| 561 | |
| 562 | // Look up the application data associated with the existing version. If there |
| 563 | // isn't any, fall back on using the hash. |
| 564 | if (existing !== undefined) { |
| 565 | const existingVersion = this.versions.get(existing)!; |
| 566 | previous = this.mergeHashWithAppData(existingVersion.manifest, existing); |
| 567 | } |
| 568 | |
| 569 | // Set the current version used by the client, and sync the mapping to disk. |
| 570 | this.clientVersionMap.set(client.id, this.latestHash!); |
| 571 | await this.sync(); |
| 572 | |
| 573 | // Notify the client about this activation. |
| 574 | const current = this.versions.get(this.latestHash!)!; |
| 575 | |
| 576 | return true; |
| 577 | } |
| 578 | |
| 579 | private async handleFetch(event: FetchEvent): Promise<Response> { |
| 580 | try { |
no test coverage detected