@@ -723,12 +723,20 @@ pub fn parse_record_to_index(data: &[u8], frs: u64, index: &mut crate::index::Mf
723723 let ext_internal_head = record. first_internal_stream ;
724724 let ext_internal_size = record. internal_streams_size ;
725725 let ext_internal_alloc = record. internal_streams_allocated ;
726+ // Snapshot first_stream.size from extension records (IOCP ordering).
727+ let ext_first_stream_len = record. first_stream . size . length ;
728+ let ext_first_stream_alloc = record. first_stream . size . allocated ;
726729
727730 record. stdinfo = std_info;
728731 record. first_stream . size = SizeInfo {
729732 length : default_size,
730733 allocated : default_allocated,
731734 } ;
735+ // Restore extension's default-stream size if base has no $DATA/$I30.
736+ if default_size == 0 && default_allocated == 0 && ( ext_first_stream_len > 0 || ext_first_stream_alloc > 0 ) {
737+ record. first_stream . size . length = ext_first_stream_len;
738+ record. first_stream . size . allocated = ext_first_stream_alloc;
739+ }
732740 // Set type_name_id for first_stream: 0 for directories ($I30), 8 for files
733741 // ($DATA)
734742 record. first_stream . flags = if record. stdinfo . is_directory ( ) {
@@ -919,12 +927,25 @@ pub fn parse_record_to_index(data: &[u8], frs: u64, index: &mut crate::index::Mf
919927 let ext_internal_head = record. first_internal_stream ;
920928 let ext_internal_size = record. internal_streams_size ;
921929 let ext_internal_alloc = record. internal_streams_allocated ;
930+ // Snapshot first_stream.size — extension records processed before the base
931+ // (due to IOCP out-of-order I/O) may have already set the default $DATA or
932+ // $I30 size. We must preserve it if the base record has no $DATA.
933+ let ext_first_stream_len = record. first_stream . size . length ;
934+ let ext_first_stream_alloc = record. first_stream . size . allocated ;
922935
923936 record. stdinfo = std_info;
924937 record. first_stream . size = SizeInfo {
925938 length : default_size,
926939 allocated : default_allocated,
927940 } ;
941+ // If the base record has no $DATA (default_size == 0 and default_allocated
942+ // == 0) but an extension record already populated first_stream.size, restore
943+ // the extension's values. This handles files/dirs whose primary $DATA/$I30
944+ // attribute resides entirely in an extension record.
945+ if default_size == 0 && default_allocated == 0 && ( ext_first_stream_len > 0 || ext_first_stream_alloc > 0 ) {
946+ record. first_stream . size . length = ext_first_stream_len;
947+ record. first_stream . size . allocated = ext_first_stream_alloc;
948+ }
928949 // Set type_name_id for first_stream: 0 for directories ($I30), 8 for files
929950 // ($DATA)
930951 record. first_stream . flags = if record. stdinfo . is_directory ( ) {
0 commit comments