@@ -510,20 +510,46 @@ impl Orogene {
510510 }
511511
512512 fn first_time_setup ( & mut self ) -> Result < ( ) > {
513- // We skip first-time-setup operations in CI entirely.
514- if self . first_time && !is_ci:: cached ( ) {
515- tracing:: info!( "Performing first-time setup..." ) ;
516- if let Some ( config_path) = self . config . clone ( ) . or_else ( || {
517- ProjectDirs :: from ( "" , "" , "orogene" )
518- . map ( |p| p. config_dir ( ) . to_owned ( ) . join ( "oro.kdl" ) )
519- } ) {
513+ if let Some ( config_path) = self . config . clone ( ) . or_else ( || {
514+ ProjectDirs :: from ( "" , "" , "orogene" )
515+ . map ( |p| p. config_dir ( ) . to_owned ( ) . join ( "oro.kdl" ) )
516+ } ) {
517+ let config_dir = config_path. parent ( ) . expect ( "must have parent" ) ;
518+ if !config_dir. exists ( ) {
519+ std:: fs:: create_dir_all ( config_dir) . expect ( "failed to create config dir" ) ;
520+ }
521+ let mut config: KdlDocument = std:: fs:: read_to_string ( & config_path)
522+ . unwrap_or_default ( )
523+ . parse ( ) ?;
524+
525+ // do we have a config file?
526+ if !config. is_empty ( ) {
527+ // restore first-time as global config
528+ if let Some ( opt) = config
529+ . get_mut ( "options" )
530+ . expect ( "must have options" )
531+ . children ( )
532+ . expect ( "options must have children" )
533+ . get ( "first-time" )
534+ {
535+ if let Some ( val) = opt. get ( 0 ) {
536+ // we've been here before; bail
537+ if !val. as_bool ( ) . unwrap_or ( false ) {
538+ self . first_time = false ;
539+ return Ok ( ( ) ) ;
540+ }
541+ }
542+ }
543+ }
544+
545+ // We skip first-time-setup operations in CI entirely.
546+ if self . first_time && !is_ci:: cached ( ) {
547+ tracing:: info!( "Performing first-time setup..." ) ;
548+
520549 let config_dir = config_path. parent ( ) . expect ( "must have parent" ) ;
521550 if !config_dir. exists ( ) {
522- std:: fs:: create_dir_all ( config_dir) . unwrap ( ) ;
551+ std:: fs:: create_dir_all ( config_dir) . expect ( "failed to create config dir" ) ;
523552 }
524- let mut config: KdlDocument = std:: fs:: read_to_string ( & config_path)
525- . unwrap_or_default ( )
526- . parse ( ) ?;
527553 let telemetry_exists = config. query ( "options > telemetry" ) ?. is_some ( ) ;
528554 if config. get ( "options" ) . is_none ( ) {
529555 config. nodes_mut ( ) . push ( KdlNode :: new ( "options" ) ) ;
@@ -580,7 +606,7 @@ impl Orogene {
580606 }
581607 std:: fs:: write ( config_path, config. to_string ( ) ) . into_diagnostic ( ) ?;
582608 }
583- }
609+ } ;
584610 Ok ( ( ) )
585611 }
586612
0 commit comments