@@ -21,7 +21,7 @@ use coffee_lib::plugin_manager::PluginManager;
21
21
use coffee_lib:: repository:: Repository ;
22
22
use coffee_lib:: types:: response:: * ;
23
23
use coffee_lib:: url:: URL ;
24
- use coffee_lib:: utils:: { copy_dir_if_exist, rm_dir_if_exist} ;
24
+ use coffee_lib:: utils:: { check_dir_or_make_if_missing , copy_dir_if_exist, rm_dir_if_exist} ;
25
25
use coffee_lib:: { commit_id, error, get_repo_info, sh} ;
26
26
use coffee_storage:: model:: repository:: { Kind , Repository as RepositoryInfo } ;
27
27
use coffee_storage:: nosql_db:: NoSQlStorage ;
@@ -80,8 +80,8 @@ pub struct CoffeeManager {
80
80
}
81
81
82
82
impl CoffeeManager {
83
- pub async fn new ( conf : & dyn CoffeeArgs ) -> Result < Self , CoffeeError > {
84
- let conf = CoffeeConf :: new ( conf ) . await ?;
83
+ pub async fn new ( conf_args : & dyn CoffeeArgs ) -> Result < Self , CoffeeError > {
84
+ let conf = CoffeeConf :: new ( conf_args ) . await ?;
85
85
let mut coffee = CoffeeManager {
86
86
config : conf. clone ( ) ,
87
87
coffee_cln_config : CLNConf :: new ( conf. config_path , true ) ,
@@ -98,6 +98,7 @@ impl CoffeeManager {
98
98
/// when coffee is configured, run an inventory to collect all the necessary information
99
99
/// about the coffee ecosystem.
100
100
async fn inventory ( & mut self ) -> Result < ( ) , CoffeeError > {
101
+ let skip_verify = self . config . skip_verify ;
101
102
let _ = self
102
103
. storage
103
104
. load :: < CoffeeStorageInfo > ( & self . config . network )
@@ -123,7 +124,7 @@ impl CoffeeManager {
123
124
if let Err ( err) = self . coffee_cln_config . parse ( ) {
124
125
log:: error!( "{}" , err. cause) ;
125
126
}
126
- if !self . config . skip_verify {
127
+ if !skip_verify {
127
128
// Check for the chain of responsibility
128
129
let status = self . recovery_strategies . scan ( self ) . await ?;
129
130
log:: debug!( "Chain of responsibility status: {:?}" , status) ;
@@ -427,15 +428,10 @@ impl PluginManager for CoffeeManager {
427
428
}
428
429
429
430
async fn add_remote ( & mut self , name : & str , url : & str ) -> Result < ( ) , CoffeeError > {
430
- // FIXME: we should allow some error here like
431
- // for the add remote command the no found error for the `repository`
432
- // directory is fine.
433
-
434
431
if self . repos . contains_key ( name) {
435
432
return Err ( error ! ( "repository with name: {name} already exists" ) ) ;
436
433
}
437
- let local_path = format ! ( "{}/{}" , self . config. root_path, self . config. network) ;
438
- let url = URL :: new ( & local_path, url, name) ;
434
+ let url = URL :: new ( & self . config . path ( ) , url, name) ;
439
435
log:: debug!( "remote adding: {} {}" , name, & url. url_string) ;
440
436
let mut repo = Github :: new ( name, & url) ;
441
437
repo. init ( ) . await ?;
@@ -551,6 +547,8 @@ impl PluginManager for CoffeeManager {
551
547
Defect :: CoffeeGlobalrepoCleanup ( networks) => {
552
548
let global_repo = format ! ( "{}/repositories" , self . config. root_path) ;
553
549
for ( network, path) in networks {
550
+ log:: info!( "{network} - {path}" ) ;
551
+ check_dir_or_make_if_missing ( path. to_owned ( ) ) . await ?;
554
552
if !Path :: exists ( Path :: new ( & path) ) {
555
553
copy_dir_if_exist ( & global_repo, path) . await ?;
556
554
}
@@ -565,6 +563,8 @@ impl PluginManager for CoffeeManager {
565
563
status : nurse_actions,
566
564
} ;
567
565
nurse. organize ( ) ;
566
+ // Refesh the status
567
+ self . flush ( ) . await ?;
568
568
Ok ( nurse)
569
569
}
570
570
@@ -587,6 +587,7 @@ impl PluginManager for CoffeeManager {
587
587
. get_mut ( repo_name)
588
588
. ok_or_else ( || error ! ( "repository with name: {repo_name} not found" ) ) ?;
589
589
590
+ repo. change_root_path ( & self . config . path ( ) ) ;
590
591
match repo. recover ( ) . await {
591
592
Ok ( _) => {
592
593
log:: info!( "repository {} recovered" , repo_name. clone( ) ) ;
0 commit comments