File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -465,7 +465,9 @@ impl File {
465465 self . inner . lock ( ) . await . complete_inflight ( ) . await ;
466466 let std = self . std . clone ( ) ;
467467 let std_file = asyncify ( move || std. try_clone ( ) ) . await ?;
468- Ok ( File :: from_std ( std_file) )
468+ let mut file = File :: from_std ( std_file) ;
469+ file. set_max_buf_size ( self . max_buf_size ) ;
470+ Ok ( file)
469471 }
470472
471473 /// Destructures `File` into a [`std::fs::File`]. This function is
Original file line number Diff line number Diff line change @@ -15,6 +15,22 @@ async fn path_read_write() {
1515 assert_eq ! ( out, b"bytes" ) ;
1616}
1717
18+ #[ tokio:: test]
19+ async fn try_clone_should_preserve_max_buf_size ( ) {
20+ let buf_size = 128 ;
21+ let temp = tempdir ( ) ;
22+ let dir = temp. path ( ) ;
23+
24+ let mut file = fs:: File :: create ( dir. join ( "try_clone_should_preserve_max_buf_size" ) )
25+ . await
26+ . unwrap ( ) ;
27+ file. set_max_buf_size ( buf_size) ;
28+
29+ let cloned = file. try_clone ( ) . await . unwrap ( ) ;
30+
31+ assert_eq ! ( cloned. max_buf_size( ) , buf_size) ;
32+ }
33+
1834fn tempdir ( ) -> tempfile:: TempDir {
1935 tempfile:: tempdir ( ) . unwrap ( )
2036}
You can’t perform that action at this time.
0 commit comments