diff options
| author | Hermes Agent <hermes@localhost> | 2026-08-12 04:01:16 +0000 |
|---|---|---|
| committer | Hermes Agent <hermes@localhost> | 2026-08-12 04:01:16 +0000 |
| commit | 196f315321643a0ce2327f750c779a7d40e4b427 (patch) | |
| tree | 700f3f67afea6f0a5086ce36782747ee63c26983 /src/manifest.rs | |
| parent | 815ec6e06e05f03022c2076f6e8573f1d2c454c9 (diff) | |
Avoid manifest collisions beside artifacts
Diffstat (limited to 'src/manifest.rs')
| -rw-r--r-- | src/manifest.rs | 18 |
1 files changed, 15 insertions, 3 deletions
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<Path>) -> Result<PathBuf> { - 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<Path>) -> Result<PathBuf> { + 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. |