@@ -70,7 +70,7 @@ impl XetClient {
7070 & self ,
7171 progress_updater : Option < Arc < dyn TrackingProgressUpdater > > ,
7272 name : Option < Arc < str > > ,
73- size : Option < u64 > ,
73+ size : u64 ,
7474 ) -> errors:: Result < XetWriter > {
7575 XetWriter :: new ( self . config . clone ( ) , progress_updater, name, size) . await
7676 }
@@ -91,12 +91,12 @@ impl XetWriter {
9191 /// Creates a new writer that will upload a single file.
9292 ///
9393 /// `size` is the total number of bytes that will be written and is used for
94- /// progress tracking. Pass `None` if the content length is not known upfront .
94+ /// progress tracking. The caller must know the content length before writing .
9595 pub async fn new (
9696 config : Arc < TranslatorConfig > ,
9797 progress_updater : Option < Arc < dyn TrackingProgressUpdater > > ,
9898 name : Option < Arc < str > > ,
99- size : Option < u64 > ,
99+ size : u64 ,
100100 ) -> errors:: Result < Self > {
101101 let session = FileUploadSession :: new ( config, progress_updater) . await ?;
102102 let handle = session. start_clean ( name, size, None ) . await ;
@@ -291,8 +291,8 @@ mod tests {
291291
292292 /// Upload `content` via [`XetWriter`] and download it back via [`XetReader`],
293293 /// asserting the round-tripped bytes match the original.
294- async fn assert_roundtrip ( client : & XetClient , content : & [ u8 ] , size : Option < u64 > ) {
295- let mut writer = client. write ( None , None , size ) . await . unwrap ( ) ;
294+ async fn assert_roundtrip ( client : & XetClient , content : & [ u8 ] ) {
295+ let mut writer = client. write ( None , None , content . len ( ) as u64 ) . await . unwrap ( ) ;
296296 for chunk in content. chunks ( 4096 ) {
297297 writer. write ( Bytes :: copy_from_slice ( chunk) ) . await . unwrap ( ) ;
298298 }
@@ -326,25 +326,12 @@ mod tests {
326326 let client = XetClient :: new ( Some ( endpoint) , None , None , "test" . into ( ) ) . unwrap ( ) ;
327327
328328 // Empty.
329- assert_roundtrip ( & client, & [ ] , Some ( 0 ) ) . await ;
329+ assert_roundtrip ( & client, & [ ] ) . await ;
330330 // Small.
331- assert_roundtrip ( & client, b"Hello, World!" , Some ( 13 ) ) . await ;
331+ assert_roundtrip ( & client, b"Hello, World!" ) . await ;
332332 // Large (1 MB).
333333 let large: Vec < u8 > = ( 0 ..1_000_000 ) . map ( |i| ( i % 256 ) as u8 ) . collect ( ) ;
334- assert_roundtrip ( & client, & large, Some ( large. len ( ) as u64 ) ) . await ;
335- }
336-
337- #[ tokio:: test]
338- async fn test_roundtrip_unknown_size ( ) {
339- let temp_dir = tempdir ( ) . unwrap ( ) ;
340- let endpoint = format ! ( "local://{}" , temp_dir. path( ) . display( ) ) ;
341- let client = XetClient :: new ( Some ( endpoint) , None , None , "test" . into ( ) ) . unwrap ( ) ;
342-
343- // Small without explicit size.
344- assert_roundtrip ( & client, b"Hello, World!" , None ) . await ;
345- // Large (1 MB) without explicit size.
346- let large: Vec < u8 > = ( 0 ..1_000_000 ) . map ( |i| ( i % 256 ) as u8 ) . collect ( ) ;
347- assert_roundtrip ( & client, & large, None ) . await ;
334+ assert_roundtrip ( & client, & large) . await ;
348335 }
349336
350337 #[ tokio:: test]
@@ -354,7 +341,7 @@ mod tests {
354341 let client = XetClient :: new ( Some ( endpoint) , None , None , "test" . into ( ) ) . unwrap ( ) ;
355342
356343 let content: Vec < u8 > = ( 0 ..1_000_000 ) . map ( |i| ( i % 256 ) as u8 ) . collect ( ) ;
357- let mut writer = client. write ( None , None , Some ( content. len ( ) as u64 ) ) . await . unwrap ( ) ;
344+ let mut writer = client. write ( None , None , content. len ( ) as u64 ) . await . unwrap ( ) ;
358345 for chunk in content. chunks ( 4096 ) {
359346 writer. write ( Bytes :: copy_from_slice ( chunk) ) . await . unwrap ( ) ;
360347 }
@@ -372,7 +359,7 @@ mod tests {
372359 let endpoint = format ! ( "local://{}" , temp_dir. path( ) . display( ) ) ;
373360 let client = XetClient :: new ( Some ( endpoint) , None , None , "test" . into ( ) ) . unwrap ( ) ;
374361
375- let mut writer = client. write ( None , None , Some ( 5 ) ) . await . unwrap ( ) ;
362+ let mut writer = client. write ( None , None , 5 ) . await . unwrap ( ) ;
376363 writer. write ( Bytes :: from_static ( b"hello" ) ) . await . unwrap ( ) ;
377364 let file_info = writer. close ( ) . await . unwrap ( ) ;
378365
@@ -429,7 +416,7 @@ mod tests {
429416 let endpoint = format ! ( "local://{}" , temp_dir. path( ) . display( ) ) ;
430417 let client = XetClient :: new ( Some ( endpoint) , None , None , "test" . into ( ) ) . unwrap ( ) ;
431418
432- let mut writer = client. write ( None , None , Some ( 100 ) ) . await . unwrap ( ) ;
419+ let mut writer = client. write ( None , None , 100 ) . await . unwrap ( ) ;
433420 writer. write ( Bytes :: from_static ( b"some data" ) ) . await . unwrap ( ) ;
434421 writer. abort ( ) . await . unwrap ( ) ;
435422
0 commit comments