use std::path::{Path, PathBuf};
use systemprompt_manifest::profile::NodeRole;
use super::AppPaths;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WritableRoot {
pub name: &'static str,
pub path: PathBuf,
}
impl WritableRoot {
fn new(name: &'static str, path: impl Into<PathBuf>) -> Self {
Self {
name,
path: path.into(),
}
}
}
impl AppPaths {
pub fn writable_roots(&self, role: NodeRole, services_cache: &Path) -> Vec<WritableRoot> {
let storage = self.storage();
let mut roots = vec![
WritableRoot::new("system.logs", self.system().logs()),
WritableRoot::new("storage.files", storage.files()),
WritableRoot::new("storage.exports", storage.exports()),
WritableRoot::new("storage.data", storage.data()),
WritableRoot::new("storage.scratch", storage.scratch()),
];
if role.runs_workers() {
roots.push(WritableRoot::new("web.dist", self.web().dist()));
roots.push(WritableRoot::new("services.cache_dir", services_cache));
}
roots
}
}