mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
make each db backend responsible for its own setup
RocksDB automatically creates parent directories already. SQLite doesn't create parent directories, only the db file if it didn't exist.
This commit is contained in:
parent
5e3825c37c
commit
f5ba3e3062
2 changed files with 3 additions and 11 deletions
|
|
@ -3,7 +3,6 @@ use std::{
|
|||
fs,
|
||||
io::Write,
|
||||
mem::size_of,
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
|
|
@ -241,16 +240,6 @@ impl KeyValueDatabase {
|
|||
"Compiled without support for any databases",
|
||||
));
|
||||
|
||||
if !Path::new(&config.database.path).exists() {
|
||||
fs::create_dir_all(&config.database.path).map_err(|_| {
|
||||
Error::BadConfig(
|
||||
"Database folder doesn't exists and couldn't be created \
|
||||
(e.g. due to missing permissions). Please create the \
|
||||
database folder yourself.",
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
let x: Arc<dyn KeyValueDatabaseEngine> = match config.database.backend {
|
||||
#[cfg(feature = "sqlite")]
|
||||
DatabaseBackend::Sqlite => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::{
|
||||
cell::RefCell,
|
||||
fs,
|
||||
future::Future,
|
||||
path::{Path, PathBuf},
|
||||
pin::Pin,
|
||||
|
|
@ -67,6 +68,8 @@ pub(crate) struct Engine {
|
|||
|
||||
impl Engine {
|
||||
pub(crate) fn open(config: &Config) -> Result<Self> {
|
||||
fs::create_dir_all(&config.database.path)?;
|
||||
|
||||
let path = Path::new(&config.database.path).join("sqlite.db");
|
||||
|
||||
// calculates cache-size per permanent connection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue