@@ -173,10 +173,7 @@ pub fn export_bundle(
173173
174174 {
175175 let src = Connection :: open_with_flags ( db_path, OpenFlags :: SQLITE_OPEN_READ_ONLY ) ?;
176- src. execute (
177- "VACUUM INTO ?1" ,
178- [ snapshot_path. to_string_lossy ( ) . as_ref ( ) ] ,
179- ) ?;
176+ src. execute ( "VACUUM INTO ?1" , [ snapshot_path. to_string_lossy ( ) . as_ref ( ) ] ) ?;
180177 }
181178
182179 // Re-open the FRESH snapshot for integrity_check and stats -- verifies
@@ -236,10 +233,7 @@ pub fn export_bundle(
236233 MANIFEST_FILE_NAME ,
237234 manifest_json. as_slice ( ) ,
238235 ) ?;
239- tar_builder
240- . into_inner ( ) ?
241- . finish ( ) ?
242- . flush ( ) ?;
236+ tar_builder. into_inner ( ) ?. finish ( ) ?. flush ( ) ?;
243237
244238 Ok ( manifest)
245239}
@@ -304,7 +298,8 @@ pub fn import_bundle(
304298 }
305299
306300 {
307- let snap = Connection :: open_with_flags ( & extracted_db_path, OpenFlags :: SQLITE_OPEN_READ_ONLY ) ?;
301+ let snap =
302+ Connection :: open_with_flags ( & extracted_db_path, OpenFlags :: SQLITE_OPEN_READ_ONLY ) ?;
308303 check_integrity ( & snap) ?;
309304 }
310305
@@ -437,21 +432,19 @@ mod tests {
437432
438433 let config = Config :: default ( ) ;
439434 let archive_path = src_dir. path ( ) . join ( "bundle.tar.gz" ) ;
440- let manifest =
441- export_bundle ( & db_path, src_dir. path ( ) , & config, & archive_path) . unwrap ( ) ;
435+ let manifest = export_bundle ( & db_path, src_dir. path ( ) , & config, & archive_path) . unwrap ( ) ;
442436 assert_eq ! ( manifest. symbol_count, 1 ) ;
443437 assert_eq ! ( manifest. file_count, 1 ) ;
444438 assert ! ( archive_path. exists( ) ) ;
445439
446440 let dest_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
447441 let dest_db_path = dest_dir. path ( ) . join ( "index.db" ) ;
448- let report =
449- import_bundle ( & archive_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap ( ) ;
442+ let report = import_bundle ( & archive_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap ( ) ;
450443 assert_eq ! ( report. manifest. symbol_count, 1 ) ;
451444 assert ! ( dest_db_path. exists( ) ) ;
452445
453- let conn = Connection :: open_with_flags ( & dest_db_path , OpenFlags :: SQLITE_OPEN_READ_ONLY )
454- . unwrap ( ) ;
446+ let conn =
447+ Connection :: open_with_flags ( & dest_db_path , OpenFlags :: SQLITE_OPEN_READ_ONLY ) . unwrap ( ) ;
455448 let count: i64 = conn
456449 . query_row ( "SELECT COUNT(*) FROM symbols" , [ ] , |r| r. get ( 0 ) )
457450 . unwrap ( ) ;
@@ -501,17 +494,33 @@ mod tests {
501494 manifest_header. set_mode ( 0o644 ) ;
502495 manifest_header. set_cksum ( ) ;
503496 builder
504- . append_data ( & mut manifest_header, MANIFEST_FILE_NAME , manifest_json. as_slice ( ) )
497+ . append_data (
498+ & mut manifest_header,
499+ MANIFEST_FILE_NAME ,
500+ manifest_json. as_slice ( ) ,
501+ )
502+ . unwrap ( ) ;
503+ builder
504+ . into_inner ( )
505+ . unwrap ( )
506+ . finish ( )
507+ . unwrap ( )
508+ . flush ( )
505509 . unwrap ( ) ;
506- builder. into_inner ( ) . unwrap ( ) . finish ( ) . unwrap ( ) . flush ( ) . unwrap ( ) ;
507510 }
508511
509512 let dest_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
510513 let dest_db_path = dest_dir. path ( ) . join ( "index.db" ) ;
511- let err = import_bundle ( & tampered_path, dest_dir. path ( ) , & dest_db_path, & config)
512- . unwrap_err ( ) ;
513- assert ! ( matches!( err, BundleError :: ChecksumMismatch { .. } ) , "{err:?}" ) ;
514- assert ! ( !dest_db_path. exists( ) , "a failed import must not touch the destination at all" ) ;
514+ let err =
515+ import_bundle ( & tampered_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap_err ( ) ;
516+ assert ! (
517+ matches!( err, BundleError :: ChecksumMismatch { .. } ) ,
518+ "{err:?}"
519+ ) ;
520+ assert ! (
521+ !dest_db_path. exists( ) ,
522+ "a failed import must not touch the destination at all"
523+ ) ;
515524 }
516525
517526 #[ test]
@@ -546,15 +555,24 @@ mod tests {
546555 manifest_header. set_mode ( 0o644 ) ;
547556 manifest_header. set_cksum ( ) ;
548557 builder
549- . append_data ( & mut manifest_header, MANIFEST_FILE_NAME , manifest_json. as_slice ( ) )
558+ . append_data (
559+ & mut manifest_header,
560+ MANIFEST_FILE_NAME ,
561+ manifest_json. as_slice ( ) ,
562+ )
563+ . unwrap ( ) ;
564+ builder
565+ . into_inner ( )
566+ . unwrap ( )
567+ . finish ( )
568+ . unwrap ( )
569+ . flush ( )
550570 . unwrap ( ) ;
551- builder. into_inner ( ) . unwrap ( ) . finish ( ) . unwrap ( ) . flush ( ) . unwrap ( ) ;
552571 }
553572
554573 let dest_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
555574 let dest_db_path = dest_dir. path ( ) . join ( "index.db" ) ;
556- let err = import_bundle ( & bumped_path, dest_dir. path ( ) , & dest_db_path, & config)
557- . unwrap_err ( ) ;
575+ let err = import_bundle ( & bumped_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap_err ( ) ;
558576 assert ! ( matches!( err, BundleError :: SchemaTooNew { .. } ) , "{err:?}" ) ;
559577 }
560578
@@ -618,16 +636,29 @@ mod tests {
618636 manifest_header. set_mode ( 0o644 ) ;
619637 manifest_header. set_cksum ( ) ;
620638 builder
621- . append_data ( & mut manifest_header, MANIFEST_FILE_NAME , manifest_json. as_slice ( ) )
639+ . append_data (
640+ & mut manifest_header,
641+ MANIFEST_FILE_NAME ,
642+ manifest_json. as_slice ( ) ,
643+ )
644+ . unwrap ( ) ;
645+ builder
646+ . into_inner ( )
647+ . unwrap ( )
648+ . finish ( )
649+ . unwrap ( )
650+ . flush ( )
622651 . unwrap ( ) ;
623- builder. into_inner ( ) . unwrap ( ) . finish ( ) . unwrap ( ) . flush ( ) . unwrap ( ) ;
624652 }
625653
626654 let dest_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
627655 let dest_db_path = dest_dir. path ( ) . join ( "index.db" ) ;
628- let err = import_bundle ( & archive_path, dest_dir. path ( ) , & dest_db_path, & config)
629- . unwrap_err ( ) ;
630- assert ! ( matches!( err, BundleError :: IntegrityCheckFailed ( _) ) , "{err:?}" ) ;
656+ let err =
657+ import_bundle ( & archive_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap_err ( ) ;
658+ assert ! (
659+ matches!( err, BundleError :: IntegrityCheckFailed ( _) ) ,
660+ "{err:?}"
661+ ) ;
631662 assert ! ( !dest_db_path. exists( ) ) ;
632663 }
633664
@@ -643,8 +674,7 @@ mod tests {
643674
644675 let dest_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
645676 let dest_db_path = dest_dir. path ( ) . join ( "index.db" ) ;
646- let report =
647- import_bundle ( & archive_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap ( ) ;
677+ let report = import_bundle ( & archive_path, dest_dir. path ( ) , & dest_db_path, & config) . unwrap ( ) ;
648678 // Both sides have no git commit -> commit_matches is conservatively
649679 // false (never assume equality from two absences), which forces a
650680 // full reindex recommendation.
0 commit comments