@@ -116,20 +116,18 @@ export class FileFetcher {
116116 #authTokens: AuthTokens ;
117117 #cache = new Map < string , LoadResponse > ( ) ;
118118 #cacheSetting: CacheSetting ;
119- #httpCache: HttpCache | undefined ;
120- #httpCachePromise: Promise < HttpCache > | undefined ;
121- #httpCacheFactory: ( ) => Promise < HttpCache > ;
119+ #httpCache: HttpCache ;
122120
123121 constructor (
124- httpCacheFactory : ( ) => Promise < HttpCache > ,
122+ httpCache : HttpCache ,
125123 cacheSetting : CacheSetting = "use" ,
126124 allowRemote = true ,
127125 ) {
128126 Deno . permissions . request ( { name : "env" , variable : "DENO_AUTH_TOKENS" } ) ;
129127 this . #authTokens = new AuthTokens ( Deno . env . get ( "DENO_AUTH_TOKENS" ) ) ;
130128 this . #allowRemote = allowRemote ;
131129 this . #cacheSetting = cacheSetting ;
132- this . #httpCacheFactory = httpCacheFactory ;
130+ this . #httpCache = httpCache ;
133131 }
134132
135133 async #fetchBlobDataUrl(
@@ -300,7 +298,7 @@ export class FileFetcher {
300298 const response = await this . #fetchBlobDataUrl(
301299 specifier ,
302300 this . #resolveOptions( options ) ,
303- await this . #resolveHttpCache ( ) ,
301+ this . #httpCache ,
304302 ) ;
305303 await this . #cache. set ( specifier . toString ( ) , response ) ;
306304 return response ;
@@ -312,7 +310,7 @@ export class FileFetcher {
312310 const response = await this . #fetchRemoteOnce(
313311 specifier ,
314312 this . #resolveOptions( options ) ,
315- await this . #resolveHttpCache ( ) ,
313+ this . #httpCache ,
316314 ) ;
317315 if ( response ) {
318316 await this . #cache. set ( specifier . toString ( ) , response ) ;
@@ -326,20 +324,6 @@ export class FileFetcher {
326324 options . cacheSetting = options . cacheSetting ?? this . #cacheSetting;
327325 return options as ResolvedFetchOptions ;
328326 }
329-
330- #resolveHttpCache( ) : Promise < HttpCache > {
331- if ( this . #httpCache != null ) {
332- return Promise . resolve ( this . #httpCache) ;
333- }
334- if ( ! this . #httpCachePromise) {
335- this . #httpCachePromise = this . #httpCacheFactory( ) . then ( ( cache ) => {
336- this . #httpCache = cache ;
337- this . #httpCachePromise = undefined ;
338- return cache ;
339- } ) ;
340- }
341- return this . #httpCachePromise;
342- }
343327}
344328
345329export async function fetchWithRetries (
0 commit comments