use std::path::Path;
use std::sync::Arc;
use object_store::ObjectStore;
use object_store::local::LocalFileSystem;
use crate::StorageError;
pub fn build(path: &Path) -> Result<Arc<dyn ObjectStore>, StorageError> {
if !path.exists() {
std::fs::create_dir_all(path).map_err(|e| {
StorageError::Config(format!("failed to create local storage dir: {e}"))
})?;
tracing::info!(path = %path.display(), "created local storage directory");
}
let store = LocalFileSystem::new_with_prefix(path)
.map_err(|e| StorageError::Config(format!("local filesystem setup failed: {e}")))?;
Ok(Arc::new(store))
}