* Possibly update a resource, if it's expired and needs to be updated. A no-op otherwise.
(
updateFrom: UpdateSource,
req: Request,
cache: Cache,
)
| 470 | * Possibly update a resource, if it's expired and needs to be updated. A no-op otherwise. |
| 471 | */ |
| 472 | protected async maybeUpdate( |
| 473 | updateFrom: UpdateSource, |
| 474 | req: Request, |
| 475 | cache: Cache, |
| 476 | ): Promise<boolean> { |
| 477 | const url = this.adapter.normalizeUrl(req.url); |
| 478 | // Check if this resource is hashed and already exists in the cache of a prior version. |
| 479 | if (this.hashes.has(url)) { |
| 480 | const hash = this.hashes.get(url)!; |
| 481 | |
| 482 | // Check the caches of prior versions, using the hash to ensure the correct version of |
| 483 | // the resource is loaded. |
| 484 | const res = await updateFrom.lookupResourceWithHash(url, hash); |
| 485 | |
| 486 | // If a previously cached version was available, copy it over to this cache. |
| 487 | if (res !== null) { |
| 488 | // Copy to this cache. |
| 489 | await cache.put(req, res); |
| 490 | |
| 491 | // No need to do anything further with this resource, it's now cached properly. |
| 492 | return true; |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | // No up-to-date version of this resource could be found. |
| 497 | return false; |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Create a new `Request` based on the specified URL and `RequestInit` options, preserving only |
nothing calls this directly
no test coverage detected
searching dependent graphs…