@@ -507,9 +507,7 @@ impl<R: Runtime> WindowManager<R> {
507
507
use crate :: api:: file:: SafePathBuf ;
508
508
use tokio:: io:: { AsyncReadExt , AsyncSeekExt } ;
509
509
use url:: Position ;
510
- let state = self . state ( ) ;
511
- let asset_scope = state. get :: < crate :: Scopes > ( ) . asset_protocol . clone ( ) ;
512
- let mime_type_cache = MimeTypeCache :: default ( ) ;
510
+ let asset_scope = self . state ( ) . get :: < crate :: Scopes > ( ) . asset_protocol . clone ( ) ;
513
511
pending. register_uri_scheme_protocol ( "asset" , move |request| {
514
512
let parsed_path = Url :: parse ( request. uri ( ) ) ?;
515
513
let filtered_path = & parsed_path[ ..Position :: AfterPath ] ;
@@ -624,7 +622,7 @@ impl<R: Runtime> WindowManager<R> {
624
622
response = response. header ( k, v) ;
625
623
}
626
624
627
- let mime_type = mime_type_cache . get_or_insert ( & data, & path) ;
625
+ let mime_type = MimeType :: parse ( & data, & path) ;
628
626
response. mimetype ( & mime_type) . status ( status_code) . body ( data)
629
627
} else {
630
628
match crate :: async_runtime:: safe_block_on ( async move { tokio:: fs:: read ( path_) . await } ) {
@@ -1429,26 +1427,6 @@ fn request_to_path(request: &tauri_runtime::http::Request, base_url: &str) -> St
1429
1427
}
1430
1428
}
1431
1429
1432
- // key is uri/path, value is the store mime type
1433
- #[ cfg( protocol_asset) ]
1434
- #[ derive( Debug , Clone , Default ) ]
1435
- struct MimeTypeCache ( Arc < Mutex < HashMap < String , String > > > ) ;
1436
-
1437
- #[ cfg( protocol_asset) ]
1438
- impl MimeTypeCache {
1439
- pub fn get_or_insert ( & self , content : & [ u8 ] , uri : & str ) -> String {
1440
- let mut cache = self . 0 . lock ( ) . unwrap ( ) ;
1441
- let uri = uri. to_string ( ) ;
1442
- if let Some ( mime_type) = cache. get ( & uri) {
1443
- mime_type. clone ( )
1444
- } else {
1445
- let mime_type = MimeType :: parse ( content, & uri) ;
1446
- cache. insert ( uri, mime_type. clone ( ) ) ;
1447
- mime_type
1448
- }
1449
- }
1450
- }
1451
-
1452
1430
#[ cfg( test) ]
1453
1431
mod tests {
1454
1432
use super :: replace_with_callback;
0 commit comments