66//! The [`Bundler`] is the public entry point. It depends on a [`BundleSource`]
77//! trait that provides repo-scoped access (local git repo + [`Prefixed`] store
88//! + `head_seq`). When `walgit_wal::Registry` lands it will implement
9- //! `BundleSource` (impl lives in this crate) and the `new` signature will
10- //! accept `Arc<Registry>` directly. Until then, [`Bundler::new_with_source`]
11- //! accepts any `BundleSource` impl (used by tests).
9+ //! `BundleSource` (impl lives in this crate) and the `new` signature will
10+ //! accept `Arc<Registry>` directly. Until then, [`Bundler::new_with_source`]
11+ //! accepts any `BundleSource` impl (used by tests).
1212//!
1313//! The core operations in [`ops`] take a [`walgit_git::LocalRepo`] + [`Prefixed`]
1414//! store so they are unit-testable with upstream `git` + [`MemoryStore`] without
@@ -171,8 +171,8 @@ impl Bundler {
171171 Arc :: new ( Self {
172172 source,
173173 cfg,
174- gates : Default :: default ( ) ,
175- lease_ttl : Duration :: from_secs ( 30 * 60 ) ,
174+ gates : parking_lot :: Mutex :: default ( ) ,
175+ lease_ttl : Duration :: from_mins ( 30 ) ,
176176 } )
177177 }
178178
@@ -190,7 +190,6 @@ impl Bundler {
190190 }
191191
192192 fn find_strategy < ' a > (
193- & self ,
194193 cfg : & ' a Config ,
195194 name : & str ,
196195 ) -> Result < & ' a walgit_config:: BundleStrategy , BundleError > {
@@ -235,7 +234,7 @@ impl Bundler {
235234 cut : & ops:: Cut ,
236235 ) -> Result < BundleEntry , BundleError > {
237236 let cfg = self . cfg_for ( handle) ;
238- let strat = self . find_strategy ( cfg, strategy_name) ?;
237+ let strat = Self :: find_strategy ( cfg, strategy_name) ?;
239238 let store = & handle. store ;
240239 let refs = slots:: default_refs ( & cfg. bundles , strat) ;
241240
@@ -295,8 +294,7 @@ impl Bundler {
295294 . iter ( )
296295 . filter ( |t| {
297296 walgit_git:: gix_hash:: ObjectId :: from_hex ( t. oid . as_bytes ( ) )
298- . map ( |o| handle. local . has_object ( & o) )
299- . unwrap_or ( false )
297+ . is_ok_and ( |o| handle. local . has_object ( & o) )
300298 } )
301299 . map ( |t| t. oid . clone ( ) )
302300 . collect ( ) ;
@@ -469,7 +467,7 @@ impl Bundler {
469467 // them as `too-small` (a later measurement or a build replaces it).
470468 let gates = self . gates . lock ( ) ;
471469 if !gates. is_empty ( ) {
472- for r in rows. iter_mut ( ) {
470+ for r in & mut rows {
473471 if r. status == slots:: SlotStatus :: Missing
474472 && let Some ( c) = gates. get ( & (
475473 handle. local . path ( ) . display ( ) . to_string ( ) ,
@@ -584,8 +582,7 @@ impl Bundler {
584582 . iter ( )
585583 . filter ( |t| {
586584 walgit_git:: gix_hash:: ObjectId :: from_hex ( t. oid . as_bytes ( ) )
587- . map ( |o| handle. local . has_object ( & o) )
588- . unwrap_or ( false )
585+ . is_ok_and ( |o| handle. local . has_object ( & o) )
589586 } )
590587 . map ( |t| t. oid . clone ( ) )
591588 . collect ( ) ;
@@ -639,12 +636,11 @@ impl Bundler {
639636 ) -> Result < Option < BundleEntry > , BundleError > {
640637 let mut handle = self . source . open_repo ( id) . await ?;
641638 let cfg = self . cfg_for ( & handle) . clone ( ) ;
642- let strat = self . find_strategy ( & cfg, strategy) ?. clone ( ) ;
639+ let strat = Self :: find_strategy ( & cfg, strategy) ?. clone ( ) ;
643640 let strat = & strat;
644641 let store = handle. store . clone ( ) ;
645- let lease = match ops:: try_acquire_lease ( & store, & strat. name , self . lease_ttl ) . await ? {
646- Some ( l) => l,
647- None => return Ok ( None ) ,
642+ let Some ( lease) = ops:: try_acquire_lease ( & store, & strat. name , self . lease_ttl ) . await ? else {
643+ return Ok ( None ) ;
648644 } ;
649645 let res: Result < Option < BundleEntry > , BundleError > = async {
650646 let fresh = ops:: read_list ( & store) . await ?. unwrap_or_default ( ) ;
@@ -697,7 +693,7 @@ impl Bundler {
697693 }
698694 Ok ( None )
699695 }
700- Err ( BundleError :: NoNewObjects ) | Err ( BundleError :: NoRefs ) => Ok ( None ) ,
696+ Err ( BundleError :: NoNewObjects | BundleError :: NoRefs ) => Ok ( None ) ,
701697 Err ( e) => Err ( e) ,
702698 }
703699 }
@@ -736,12 +732,10 @@ impl Bundler {
736732 if missing. is_empty ( ) {
737733 continue ;
738734 }
739- let lease = match ops:: try_acquire_lease ( store, & strat. name , self . lease_ttl ) . await ? {
740- Some ( l) => l,
741- None => {
742- debug ! ( strategy = %strat. name, "lease held, skipping" ) ;
743- continue ;
744- }
735+ let Some ( lease) = ops:: try_acquire_lease ( store, & strat. name , self . lease_ttl ) . await ?
736+ else {
737+ debug ! ( strategy = %strat. name, "lease held, skipping" ) ;
738+ continue ;
745739 } ;
746740 let res: Result < ( ) , BundleError > = async {
747741 if !prepared {
@@ -853,14 +847,10 @@ pub async fn bundle_engine(handle: &walgit_wal::RepoHandle) -> BundleEngine {
853847 }
854848 }
855849 }
856- let linked = handle
857- . local ( )
858- . packs ( )
859- . map ( |ps| {
860- ps. iter ( )
861- . any ( |p| handle. local ( ) . pack_path ( & p. checksum ) . is_symlink ( ) )
862- } )
863- . unwrap_or ( false ) ;
850+ let linked = handle. local ( ) . packs ( ) . is_ok_and ( |ps| {
851+ ps. iter ( )
852+ . any ( |p| handle. local ( ) . pack_path ( & p. checksum ) . is_symlink ( ) )
853+ } ) ;
864854 if linked {
865855 return BundleEngine :: Gix { faulter : None } ;
866856 }
@@ -869,7 +859,7 @@ pub async fn bundle_engine(handle: &walgit_wal::RepoHandle) -> BundleEngine {
869859
870860#[ cfg( feature = "wal" ) ]
871861mod wal_impl {
872- use super :: * ;
862+ use super :: { BundleEngine , BundleError , BundleRepoHandle , BundleSource , RepoId , bundle_engine } ;
873863 use walgit_wal:: { Registry , WalError } ;
874864
875865 fn wal_err ( e : WalError ) -> BundleError {
0 commit comments