File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -194,19 +194,23 @@ pub async fn git_receive_pack(
194
194
let mut data_stream = req. into_body ( ) . into_data_stream ( ) ;
195
195
let mut report_status = Bytes :: new ( ) ;
196
196
197
+ let mut chunk_buffer = BytesMut :: new ( ) ; // Used to cache the data of chunks before the PACK subsequence is found.
197
198
// Process the data stream to handle the Git receive-pack protocol.
198
199
while let Some ( chunk) = data_stream. next ( ) . await {
199
200
let chunk = chunk. unwrap ( ) ;
200
201
// Process the data up to the "PACK" subsequence.
201
202
if let Some ( pos) = search_subsequence ( & chunk, b"PACK" ) {
202
- pack_protocol. git_receive_pack_protocol ( Bytes :: copy_from_slice ( & chunk[ 0 ..pos] ) ) ;
203
+ chunk_buffer. extend_from_slice ( & chunk[ 0 ..pos] ) ;
204
+ pack_protocol. git_receive_pack_protocol ( Bytes :: copy_from_slice ( & chunk_buffer) ) ;
203
205
// Create a new stream from the remaining bytes and the rest of the data stream.
204
- let remaining_bytes = Bytes :: copy_from_slice ( & chunk[ pos..] ) ;
205
- let remaining_stream = stream:: once ( async { Ok ( remaining_bytes ) } ) . chain ( data_stream) ;
206
+ let left_chunk_bytes = Bytes :: copy_from_slice ( & chunk[ pos..] ) ;
207
+ let pack_stream = stream:: once ( async { Ok ( left_chunk_bytes ) } ) . chain ( data_stream) ;
206
208
report_status = pack_protocol
207
- . git_receive_pack_stream ( Box :: pin ( remaining_stream ) )
209
+ . git_receive_pack_stream ( Box :: pin ( pack_stream ) )
208
210
. await ?;
209
211
break ;
212
+ } else {
213
+ chunk_buffer. extend_from_slice ( & chunk) ;
210
214
}
211
215
}
212
216
tracing:: info!( "report status:{:?}" , report_status) ;
You can’t perform that action at this time.
0 commit comments