From 0ea71065b7f9a3ac1fe8fb14ac23acd556c2850b Mon Sep 17 00:00:00 2001 From: vasilito Date: Thu, 18 Jun 2026 16:48:33 +0300 Subject: [PATCH] fix(cookbook): copy path source in fetch_offline() too (was only in fetch()) fetch_offline() is called for protected recipes (base, kernel, relibc, etc.) when REDBEAR_ALLOW_PROTECTED_FETCH=1 is set. Previously, its Path source arm called only redbear_ensure_offline_source() which fails with 'is not exist' if the source dir is empty. The fix: do the same copy_dir_all() in fetch_offline()'s Path arm as in fetch()'s Path arm. This means local fork paths (local/sources/base, local/sources/relibc, etc.) are correctly copied into recipes//source during protected recipe fetch. --- src/cook/fetch.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cook/fetch.rs b/src/cook/fetch.rs index 9c4e3efa41..93ec3dd189 100644 --- a/src/cook/fetch.rs +++ b/src/cook/fetch.rs @@ -354,10 +354,23 @@ pub fn fetch_offline(recipe: &CookRecipe, logger: &PtyOut) -> Result { - redbear_ensure_offline_source(recipe_dir, &source_dir, logger)?; - let ident = fetch_apply_source_info(recipe, "".to_string())?; - FetchResult::cached(source_dir, ident) + Some(SourceRecipe::Path { path }) => { + let path = recipe_dir.join(path); + let cached = source_dir.is_dir() && modified_dir(&path)? <= modified_dir(&source_dir)?; + if !cached { + log_to_pty!( + logger, + "[DEBUG]: {:?} is newer than {:?}", + path.display(), + source_dir.display() + ); + copy_dir_all(&path, &source_dir).map_err(wrap_io_err!( + &path, + source_dir, + "Copying source" + ))?; + } + FetchResult::new(source_dir, "local_source".to_string(), cached) } None => { let ident = fetch_apply_source_info(recipe, "".to_string())?;