Directories for database file, backups and logs are defined in configuration file now
This commit is contained in:
parent
18e4f846fb
commit
b4411ae892
6 changed files with 118 additions and 44 deletions
|
|
@ -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: {}",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue