canic_host/release_set/paths/
artifacts.rs1use std::{
2 fs,
3 path::{Path, PathBuf},
4};
5use thiserror::Error as ThisError;
6
7use super::super::ROOT_RELEASE_SET_MANIFEST_FILE;
8
9#[derive(Debug, Eq, PartialEq, ThisError)]
11pub enum ArtifactRootError {
12 #[error("missing built ICP artifacts under {artifact_root}")]
13 Missing { artifact_root: PathBuf },
14}
15
16pub fn resolve_artifact_root(icp_root: &Path, network: &str) -> Result<PathBuf, ArtifactRootError> {
18 let artifact_root = icp_root.join(".icp").join(network).join("canisters");
19 if artifact_root.is_dir() {
20 return Ok(artifact_root);
21 }
22
23 Err(ArtifactRootError::Missing { artifact_root })
24}
25
26pub fn root_release_set_manifest_path(
28 artifact_root: &Path,
29) -> Result<PathBuf, Box<dyn std::error::Error>> {
30 let manifest_path = artifact_root
31 .join("root")
32 .join(ROOT_RELEASE_SET_MANIFEST_FILE);
33
34 if let Some(parent) = manifest_path.parent() {
35 fs::create_dir_all(parent)?;
36 }
37
38 Ok(manifest_path)
39}