Directories for database file, backups and logs are defined in configuration file now

This commit is contained in:
Greg Burri 2025-04-12 15:58:19 +02:00
parent 18e4f846fb
commit b4411ae892
6 changed files with 118 additions and 44 deletions

View file

@ -16,6 +16,10 @@ pub fn start<P>(
where
P: AsRef<std::path::Path> + Send + Sync + 'static,
{
if !directory.as_ref().exists() {
std::fs::DirBuilder::new().create(&directory).unwrap();
}
if !directory.as_ref().is_dir() {
panic!(
"Path must be a directory: {}",

View file

@ -51,8 +51,11 @@ pub struct Connection {
}
impl Connection {
pub async fn new() -> Result<Connection> {
let path = Path::new(consts::DB_DIRECTORY).join(consts::DB_FILENAME);
pub async fn new<P>(directory: P) -> Result<Connection>
where
P: AsRef<Path>,
{
let path = directory.as_ref().join(consts::DB_FILENAME);
Self::new_from_file(path).await
}