@@ -20,31 +20,28 @@ use tracing::{debug, info, trace};
2020/// Run the registry watcher
2121/// NOTE: this should only be run once, otherwise crates would be added
2222/// to the queue multiple times.
23- pub async fn watch_registry (
24- build_queue : & AsyncBuildQueue ,
25- config : & Config ,
26- index : & Index ,
27- ) -> Result < ( ) , Error > {
23+ pub async fn watch_registry ( build_queue : & AsyncBuildQueue , config : & Config ) -> Result < ( ) , Error > {
2824 let mut last_gc = Instant :: now ( ) ;
2925
3026 loop {
3127 if build_queue. is_locked ( ) . await ? {
3228 debug ! ( "Queue is locked, skipping checking new crates" ) ;
3329 } else {
3430 debug ! ( "Checking new crates" ) ;
31+ let index = Index :: from_config ( config) . await ?;
3532 match build_queue
36- . get_new_crates ( index)
33+ . get_new_crates ( & index)
3734 . await
3835 . context ( "Failed to get new crates" )
3936 {
4037 Ok ( n) => debug ! ( "{} crates added to queue" , n) ,
4138 Err ( e) => report_error ( & e) ,
4239 }
43- }
4440
45- if last_gc. elapsed ( ) . as_secs ( ) >= config. registry_gc_interval {
46- index. run_git_gc ( ) . await ;
47- last_gc = Instant :: now ( ) ;
41+ if last_gc. elapsed ( ) . as_secs ( ) >= config. registry_gc_interval {
42+ index. run_git_gc ( ) . await ;
43+ last_gc = Instant :: now ( ) ;
44+ }
4845 }
4946 tokio:: time:: sleep ( config. delay_between_registry_fetches ) . await ;
5047 }
@@ -58,8 +55,7 @@ fn start_registry_watcher(context: &Context) -> Result<(), Error> {
5855 // space this out to prevent it from clashing against the queue-builder thread on launch
5956 tokio:: time:: sleep ( Duration :: from_secs ( 30 ) ) . await ;
6057
61- let index = Index :: from_config ( & config) . await ?;
62- watch_registry ( & build_queue, & config, & index) . await
58+ watch_registry ( & build_queue, & config) . await
6359 } ) ;
6460
6561 Ok ( ( ) )
0 commit comments