use crate::storage::{Storage, StorageError};
impl Storage {
pub fn create_schema_dir(&self, db_name: &str, schema_name: &str) -> Result<(), StorageError> {
let db_path = self.database_path(db_name);
if !db_path.exists() {
return Err(StorageError::DirectoryNotFound(db_path));
}
let schema_path = self.schema_path(db_name, schema_name);
if schema_path.exists() {
return Err(StorageError::DirectoryAlreadyExists(schema_path));
}
std::fs::create_dir(&schema_path).map_err(|e| StorageError::io(&schema_path, e))?;
Ok(())
}
pub fn drop_schema_dir(&self, db_name: &str, schema_name: &str) -> Result<(), StorageError> {
let schema_path = self.schema_path(db_name, schema_name);
if !schema_path.exists() {
return Err(StorageError::DirectoryNotFound(schema_path));
}
std::fs::remove_dir_all(&schema_path).map_err(|e| StorageError::io(&schema_path, e))?;
Ok(())
}
}