From 6f260fac3ef0482e779b37652d7e0853a08df566 Mon Sep 17 00:00:00 2001 From: shmuelbiller1 Date: Fri, 9 Oct 2026 14:36:06 -0400 Subject: [PATCH] fix(package): propagate optional metadata for cyclic links without nesting Options --- crates/engine/src/cmd/package.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/package.rs b/crates/engine/src/cmd/package.rs index 2ae32e36..d7198056 100644 --- a/crates/engine/src/cmd/package.rs +++ b/crates/engine/src/cmd/package.rs @@ -140,7 +140,8 @@ impl<'a> Collector<'a> { fn collect(&mut self, doc: &mut Document, source: &str, destination: &str, depth: usize) -> Result<()> { // The caller checks cycles and depth before descending; active documents have // a destination reserved so back-links can point at their single packaged copy. - self.visiting.insert(source.to_string(), destination.to_string()); + let previous = self.visiting.insert(source.to_string(), destination.to_string()); + debug_assert!(previous.is_none(), "collector visits each document once"); // A file's saved path is only meaningful inside its own document. // Different linked documents can reuse the same stale absolute path yet // resolve it to distinct local assets. Keep a mapping per document. @@ -258,13 +259,13 @@ impl<'a> Collector<'a> { let relative = relative_in_package(destination, ©.name); link.path = self.root.as_ref().map_or_else(|| copy.name.clone(), |r| r.join(©.name).to_string_lossy().into_owned()); link.relative = Some(relative); - link.size = Some(copy.size); - link.hash = Some(copy.hash.clone()); + link.size = copy.size; + link.hash = copy.hash.clone(); link.modified = None; } }); } - self.visiting.remove(source); + let _ = self.visiting.remove(source); Ok(()) } }