Reread recipe TOML on TUI retry

This commit is contained in:
Wildan M 2025-12-06 22:00:25 +07:00
parent 3ae5da8d13
commit 96d2d5dfe7
No known key found for this signature in database
GPG Key ID: 01AC53185C679C79
2 changed files with 10 additions and 2 deletions

View File

@ -1008,7 +1008,7 @@ fn run_tui_cook(
let cooker_status_tx = status_tx.clone();
let cooker_prompting = prompting.clone();
let cooker_handle = thread::spawn(move || {
'done: for (recipe, source_dir) in work_rx {
'done: for (mut recipe, source_dir) in work_rx {
let name = recipe.name.clone();
let is_deps = recipe.is_deps;
let (mut stdout_writer, mut stderr_writer) = setup_logger(&cooker_status_tx, &name);
@ -1017,6 +1017,7 @@ fn run_tui_cook(
cooker_status_tx
.send(StatusUpdate::StartCook(name.clone()))
.unwrap();
let _ = recipe.reload_recipe(); // reread recipe.toml in case we're retrying
let handler = handle_cook(
&recipe,
&cooker_config,
@ -1113,7 +1114,7 @@ fn run_tui_cook(
let fetcher_config = config.clone();
let fetcher_prompting = prompting.clone();
let fetcher_handle = thread::spawn(move || {
'done: for recipe in fetcher_recipes {
'done: for mut recipe in fetcher_recipes {
let name = recipe.name.clone();
let (mut stdout_writer, mut stderr_writer) = setup_logger(&fetcher_status_tx, &name);
let mut logger = Some((&mut stdout_writer, &mut stderr_writer));
@ -1121,6 +1122,7 @@ fn run_tui_cook(
fetcher_status_tx
.send(StatusUpdate::StartFetch(name.clone()))
.unwrap();
let _ = recipe.reload_recipe(); // reread recipe.toml in case we're retrying
let handler = handle_fetch(&recipe, &fetcher_config, true, &logger);
if let Some(log_path) = fetcher_config.logs_dir.as_ref()
// successful fetch log usually not that helpful

View File

@ -416,6 +416,12 @@ impl CookRecipe {
Ok(packages.into_iter().map(|p| p.name).collect())
}
pub fn reload_recipe(&mut self) -> Result<(), PackageError> {
let r = Self::from_path(&self.dir, true)?;
self.recipe = r.recipe;
Ok(())
}
/// returns stage dir, pkgar file and toml file.
pub fn stage_paths(&self) -> (PathBuf, PathBuf, PathBuf) {
let r = self.name.suffix().map(|p| OptionalPackageRecipe {