File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -645,12 +645,20 @@ where
645
645
646
646
let mut offset = 0 ;
647
647
let end = snapshot. snapshot . seek ( SeekFrom :: End ( 0 ) ) . await . sto_res ( err_x) ?;
648
- let mut buf = Vec :: with_capacity ( self . config . snapshot_max_chunk_size as usize ) ;
649
648
650
649
loop {
651
650
// Build the RPC.
652
651
snapshot. snapshot . seek ( SeekFrom :: Start ( offset) ) . await . sto_res ( err_x) ?;
653
- let n_read = snapshot. snapshot . read_buf ( & mut buf) . await . sto_res ( err_x) ?;
652
+
653
+ let mut buf = Vec :: with_capacity ( self . config . snapshot_max_chunk_size as usize ) ;
654
+ while buf. capacity ( ) > buf. len ( ) {
655
+ let n = snapshot. snapshot . read_buf ( & mut buf) . await . sto_res ( err_x) ?;
656
+ if n == 0 {
657
+ break ;
658
+ }
659
+ }
660
+
661
+ let n_read = buf. len ( ) ;
654
662
655
663
let leader_time = <C :: AsyncRuntime as AsyncRuntime >:: Instant :: now ( ) ;
656
664
@@ -659,10 +667,9 @@ where
659
667
vote : self . session_id . vote ,
660
668
meta : snapshot. meta . clone ( ) ,
661
669
offset,
662
- data : Vec :: from ( & buf[ ..n_read ] ) ,
670
+ data : buf,
663
671
done,
664
672
} ;
665
- buf. clear ( ) ;
666
673
667
674
// Send the RPC over to the target.
668
675
tracing:: debug!(
You can’t perform that action at this time.
0 commit comments