use anyhow::{Context, Result};
use std::{path::PathBuf, sync::OnceLock};
use crate::config::get_config_path;
static SNAP_PATH: OnceLock<PathBuf> = OnceLock::new();
pub fn get_snapshot_path() -> Result<PathBuf> {
if let Some(cached) = SNAP_PATH.get().cloned() {
return Ok(cached);
}
let config_parent = get_config_path()
.parent()
.with_context(|| "Could not determine config parent directory".to_string())?
.to_path_buf();
let new_path = config_parent.join("snapshot.json");
SNAP_PATH.set(new_path.clone()).ok();
Ok(new_path)
}