From 196f315321643a0ce2327f750c779a7d40e4b427 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 04:01:16 +0000 Subject: Avoid manifest collisions beside artifacts --- src/manifest.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/manifest.rs') diff --git a/src/manifest.rs b/src/manifest.rs index 8e9d13c..3a34af7 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -46,14 +46,26 @@ impl ArtifactManifest { } pub fn write_beside(&self, artifact: impl AsRef) -> Result { - let artifact = artifact.as_ref(); - let directory = artifact.parent().unwrap_or_else(|| Path::new(".")); - let path = directory.join("artifact.manifest.toml"); + let path = Self::path_beside(artifact)?; let text = toml::to_string_pretty(self).context("serialize artifact manifest")?; fs::write(&path, text).with_context(|| format!("write artifact manifest {}", path.display()))?; Ok(path) } + /// Return the unambiguous companion-manifest path for one artifact. + /// Keeping the artifact filename prevents legacy and native manifests from + /// overwriting one another when both are written to the comparison output + /// directory. + pub fn path_beside(artifact: impl AsRef) -> Result { + let artifact = artifact.as_ref(); + let name = artifact + .file_name() + .ok_or_else(|| anyhow::anyhow!("artifact path has no filename: {}", artifact.display()))?; + let mut manifest_name = name.to_os_string(); + manifest_name.push(".manifest.toml"); + Ok(artifact.with_file_name(manifest_name)) + } + /// Collect native filesystem and archive facts from a completed build. /// Package records come from the typed package-installation boundary because /// the RPM database is not a portable filesystem format. -- cgit v1.2.3