@@ -915,13 +915,40 @@ impl MftReader {
915915 /// Use this when you need fast indexing and searching. Convert to DataFrame
916916 /// later with `MftIndex::to_dataframe()` if you need Polars analytics.
917917 ///
918+ /// # Note
919+ ///
920+ /// This function uses `spawn_blocking` internally to run MFT reading on a
921+ /// dedicated blocking thread. This avoids potential nested tokio runtime
922+ /// issues that can occur when dependencies (like polars) try to create
923+ /// their own runtime.
924+ ///
918925 /// # Errors
919926 ///
920927 /// Returns an error if MFT reading fails.
921928 #[ cfg( windows) ]
922- #[ allow( clippy:: unused_async) ]
923929 pub async fn read_all_index ( & self ) -> Result < crate :: index:: MftIndex > {
924- self . read_mft_index_internal ( None :: < fn ( MftProgress ) > )
930+ // Capture configuration to recreate reader in blocking thread
931+ let volume = self . volume ;
932+ let mode = self . mode ;
933+ let merge_extensions = self . merge_extensions ;
934+ let use_bitmap = self . use_bitmap ;
935+ let expand_hardlinks = self . expand_hardlinks ;
936+
937+ tokio:: task:: spawn_blocking ( move || {
938+ // Create a new reader in the blocking thread
939+ let handle = crate :: platform:: VolumeHandle :: open ( volume) ?;
940+ let reader = MftReader {
941+ volume,
942+ handle,
943+ mode,
944+ merge_extensions,
945+ use_bitmap,
946+ expand_hardlinks,
947+ } ;
948+ reader. read_mft_index_internal ( None :: < fn ( MftProgress ) > )
949+ } )
950+ . await
951+ . map_err ( |e| MftError :: InvalidInput ( format ! ( "Task join error: {e}" ) ) ) ?
925952 }
926953
927954 /// Read MFT into lean index (non-Windows stub).
@@ -994,16 +1021,42 @@ impl MftReader {
9941021 ///
9951022 /// * `callback` - Function called periodically with progress updates
9961023 ///
1024+ /// # Note
1025+ ///
1026+ /// This function uses `spawn_blocking` internally to run MFT reading on a
1027+ /// dedicated blocking thread. This avoids potential nested tokio runtime
1028+ /// issues.
1029+ ///
9971030 /// # Errors
9981031 ///
9991032 /// Returns an error if MFT reading fails.
10001033 #[ cfg( windows) ]
1001- #[ allow( clippy:: unused_async) ]
10021034 pub async fn read_index_with_progress < F > ( & self , callback : F ) -> Result < crate :: index:: MftIndex >
10031035 where
10041036 F : Fn ( MftProgress ) + Send + ' static ,
10051037 {
1006- self . read_mft_index_internal ( Some ( callback) )
1038+ // Capture configuration to recreate reader in blocking thread
1039+ let volume = self . volume ;
1040+ let mode = self . mode ;
1041+ let merge_extensions = self . merge_extensions ;
1042+ let use_bitmap = self . use_bitmap ;
1043+ let expand_hardlinks = self . expand_hardlinks ;
1044+
1045+ tokio:: task:: spawn_blocking ( move || {
1046+ // Create a new reader in the blocking thread
1047+ let handle = crate :: platform:: VolumeHandle :: open ( volume) ?;
1048+ let reader = MftReader {
1049+ volume,
1050+ handle,
1051+ mode,
1052+ merge_extensions,
1053+ use_bitmap,
1054+ expand_hardlinks,
1055+ } ;
1056+ reader. read_mft_index_internal ( Some ( callback) )
1057+ } )
1058+ . await
1059+ . map_err ( |e| MftError :: InvalidInput ( format ! ( "Task join error: {e}" ) ) ) ?
10071060 }
10081061
10091062 /// Read MFT into lean index with progress (non-Windows stub).
0 commit comments