@@ -137,7 +137,6 @@ impl HttpCache {
137
137
if status == 304 {
138
138
if let Some ( cached) = cached_result {
139
139
let new_valid_until = valid_until. max ( cached. meta . valid_until ) ;
140
- println ! ( "GET {} [{}] (unchanged)" , url, status) ;
141
140
return Ok ( FetchResultType :: Content ( ContentFetchResult {
142
141
meta : FetchResultMeta {
143
142
fresh : true ,
@@ -154,7 +153,6 @@ impl HttpCache {
154
153
// Improved handling of redirects to match webpack
155
154
if let Some ( location) = location {
156
155
if ( 301 ..=308 ) . contains ( & status) {
157
- println ! ( "GET {} [{}] -> {}" , url, status, location) ;
158
156
// Resolve relative redirects like webpack does
159
157
let absolute_location = match Url :: parse ( & location) {
160
158
Ok ( loc) => loc. to_string ( ) , // Already absolute
@@ -181,7 +179,6 @@ impl HttpCache {
181
179
&& cached_redirect. meta . store_cache == store_cache
182
180
&& cached_redirect. meta . etag == etag
183
181
{
184
- println ! ( "GET {} [{}] (unchanged redirect)" , url, status) ;
185
182
return Ok ( FetchResultType :: Redirect ( RedirectFetchResult {
186
183
meta : FetchResultMeta {
187
184
fresh : true ,
@@ -215,14 +212,6 @@ impl HttpCache {
215
212
}
216
213
217
214
let content = response. body ;
218
- println ! (
219
- "GET {} [{}] {} kB{}" ,
220
- url,
221
- status,
222
- content. len( ) / 1024 ,
223
- if !store_lock { " no-cache" } else { "" }
224
- ) ;
225
-
226
215
let integrity = compute_integrity ( & content) ;
227
216
let content_type = headers
228
217
. get ( "content-type" )
@@ -249,14 +238,6 @@ impl HttpCache {
249
238
} ,
250
239
} ;
251
240
252
- if !store_cache {
253
- println ! (
254
- "{} can't be stored in cache, due to Cache-Control header: {}" ,
255
- url,
256
- cache_control. unwrap_or_else( || "null" . to_string( ) )
257
- ) ;
258
- }
259
-
260
241
if store_cache || store_lock {
261
242
let should_update = cached_result
262
243
. map ( |cached| {
@@ -274,23 +255,7 @@ impl HttpCache {
274
255
let lockfile = self . lockfile_cache . get_lockfile ( ) . await ?;
275
256
let mut lock_guard = lockfile. lock ( ) . await ;
276
257
277
- // Log entry updates similar to webpack
278
- let old_entry = lock_guard. get_entry ( url) ;
279
- if let Some ( old_entry) = old_entry {
280
- if old_entry. integrity != entry. integrity {
281
- println ! ( "{} updated in lockfile: content changed" , url) ;
282
- } else if old_entry. content_type != entry. content_type {
283
- println ! (
284
- "{} updated in lockfile: {} -> {}" ,
285
- url, old_entry. content_type, entry. content_type
286
- ) ;
287
- } else {
288
- println ! ( "{} updated in lockfile" , url) ;
289
- }
290
- } else {
291
- println ! ( "{} added to lockfile" , url) ;
292
- }
293
-
258
+ // Update the lockfile entry
294
259
lock_guard. entries_mut ( ) . insert ( url. to_string ( ) , entry) ;
295
260
drop ( lock_guard) ;
296
261
self . lockfile_cache . save_lockfile ( ) . await ?;
@@ -306,35 +271,26 @@ impl HttpCache {
306
271
let lock_guard = lockfile. lock ( ) . await ;
307
272
308
273
if let Some ( entry) = lock_guard. get_entry ( resource) {
309
- // Generate cache key using webpack-compatible format
310
274
let cache_key = self . get_cache_key ( & entry. resolved ) ;
311
-
312
- // Full path to the cache file
313
- let cache_path_buf = PathBuf :: from ( cache_location) . join ( & cache_key) ;
275
+ let cache_path_buf = cache_location. join ( & cache_key) ;
314
276
let cache_path = Utf8Path :: from_path ( & cache_path_buf) . expect ( "Invalid cache path" ) ;
315
277
316
- // Try to read the file
317
- match self . filesystem . read_file ( cache_path) . await {
318
- Ok ( content) => {
319
- let meta = FetchResultMeta {
320
- store_cache : true ,
321
- store_lock : true ,
322
- valid_until : entry. valid_until ,
323
- etag : entry. etag . clone ( ) ,
324
- fresh : entry. valid_until >= current_time ( ) ,
325
- } ;
326
-
327
- let result = ContentFetchResult {
328
- entry : entry. clone ( ) ,
329
- content,
330
- meta,
331
- } ;
332
-
333
- return Ok ( Some ( result) ) ;
334
- }
335
- Err ( e) => {
336
- println ! ( "Failed to read cache file: {:?}" , e) ;
337
- }
278
+ if let Ok ( content) = self . filesystem . read_file ( cache_path) . await {
279
+ let meta = FetchResultMeta {
280
+ store_cache : true ,
281
+ store_lock : true ,
282
+ valid_until : entry. valid_until ,
283
+ etag : entry. etag . clone ( ) ,
284
+ fresh : entry. valid_until >= current_time ( ) ,
285
+ } ;
286
+
287
+ let result = ContentFetchResult {
288
+ entry : entry. clone ( ) ,
289
+ content,
290
+ meta,
291
+ } ;
292
+
293
+ return Ok ( Some ( result) ) ;
338
294
}
339
295
}
340
296
}
@@ -343,8 +299,6 @@ impl HttpCache {
343
299
344
300
async fn write_to_cache ( & self , resource : & str , content : & [ u8 ] ) -> Result < ( ) > {
345
301
if let Some ( cache_location) = & self . cache_location {
346
- println ! ( "Writing to cache at location: {:?}" , cache_location) ;
347
-
348
302
// Generate cache key using webpack-compatible format
349
303
let cache_key = self . get_cache_key ( resource) ;
350
304
@@ -355,22 +309,12 @@ impl HttpCache {
355
309
// Create parent directories
356
310
if let Some ( parent) = cache_path. parent ( ) {
357
311
let parent_path = parent. to_string ( ) ;
358
- println ! ( "Creating directory: {:?}" , parent_path) ;
359
312
let parent_utf8_path = Utf8Path :: new ( & parent_path) ;
360
- match self . filesystem . create_dir_all ( parent_utf8_path) . await {
361
- Ok ( _) => println ! ( "Created cache directory successfully" ) ,
362
- Err ( e) => println ! ( "Failed to create cache directory: {:?}" , e) ,
363
- } ;
313
+ self . filesystem . create_dir_all ( parent_utf8_path) . await . ok ( ) ;
364
314
}
365
315
366
316
// Write the cache file
367
- println ! ( "Writing cache file to: {:?}" , cache_path) ;
368
- match self . filesystem . write ( cache_path, content) . await {
369
- Ok ( _) => println ! ( "Wrote cache file successfully" ) ,
370
- Err ( e) => println ! ( "Failed to write cache file: {:?}" , e) ,
371
- } ;
372
- } else {
373
- println ! ( "No cache location specified" ) ;
317
+ self . filesystem . write ( cache_path, content) . await . ok ( ) ;
374
318
}
375
319
Ok ( ( ) )
376
320
}
0 commit comments