1- use std:: {
2- fs,
3- path:: { Path , PathBuf } ,
4- } ;
1+ use std:: { fs, path:: PathBuf } ;
52
63use rustyline:: Editor ;
74
@@ -127,14 +124,15 @@ pub async fn update_env_images(
127124pub async fn upgrade_app ( context : & mut CommandContext ) -> Result < ( ) > {
128125 log:: info!( "Upgrading the application" ) ;
129126 // get template data
130- let template_data = template:: get_template_data ( ) . await ?;
131- let git_dir = Path :: new ( LENRA_CACHE_DIRECTORY ) . join ( template:: TEMPLATE_GIT_DIR ) ;
127+ let template_data = template:: get_template_data ( context) . await ?;
128+ let cache_dir = context. resolve_path ( & PathBuf :: from ( LENRA_CACHE_DIRECTORY ) ) ;
129+ let git_dir = cache_dir. join ( template:: TEMPLATE_GIT_DIR ) ;
132130
133131 if git_dir. is_dir ( ) {
134132 // update the template repo
135133 git:: pull ( Some ( git_dir. clone ( ) ) ) . await ?;
136134 } else {
137- let template_tmp = Path :: new ( LENRA_CACHE_DIRECTORY ) . join ( template:: TEMPLATE_TEMP_DIR ) ;
135+ let template_tmp = cache_dir . join ( template:: TEMPLATE_TEMP_DIR ) ;
138136 // clone template project
139137 template:: clone_template ( template_data. template . as_str ( ) , & template_tmp) . await ?;
140138 fs:: rename ( template_tmp. join ( ".git" ) , git_dir. clone ( ) ) ?;
@@ -149,8 +147,7 @@ pub async fn upgrade_app(context: &mut CommandContext) -> Result<()> {
149147 }
150148
151149 // get diff between previous commit and current commit
152- let patch_file = Path :: new ( LENRA_CACHE_DIRECTORY )
153- . join ( format ! ( "patch.{}-{}.diff" , commit, current_commit) ) ;
150+ let patch_file = cache_dir. join ( format ! ( "patch.{}-{}.diff" , commit, current_commit) ) ;
154151 log:: debug!(
155152 "create patch between {} and {}: {:?}" ,
156153 commit,
@@ -218,7 +215,7 @@ pub async fn upgrade_app(context: &mut CommandContext) -> Result<()> {
218215 template : template_data. template ,
219216 commit : Some ( current_commit) ,
220217 }
221- . save ( )
218+ . save ( context )
222219 . await
223220}
224221
0 commit comments