mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
make database path a pathbuf
I'm guessing it wasn't like this already because of one of the admin commands I deleted.
This commit is contained in:
parent
5a5608e088
commit
81a449d1d2
3 changed files with 7 additions and 8 deletions
|
|
@ -327,7 +327,7 @@ impl Display for DatabaseBackend {
|
|||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct DatabaseConfig {
|
||||
pub(crate) backend: DatabaseBackend,
|
||||
pub(crate) path: String,
|
||||
pub(crate) path: PathBuf,
|
||||
#[serde(default = "default_db_cache_capacity_mb")]
|
||||
pub(crate) cache_capacity_mb: f64,
|
||||
#[cfg(feature = "rocksdb")]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use std::{
|
|||
fs,
|
||||
io::Write,
|
||||
mem::size_of,
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
|
|
@ -234,9 +233,9 @@ pub(crate) struct KeyValueDatabase {
|
|||
|
||||
impl KeyValueDatabase {
|
||||
fn check_db_setup(config: &Config) -> Result<()> {
|
||||
let path = Path::new(&config.database.path);
|
||||
|
||||
let sqlite_exists = path
|
||||
let sqlite_exists = config
|
||||
.database
|
||||
.path
|
||||
.join(format!(
|
||||
"{}.db",
|
||||
if config.conduit_compat {
|
||||
|
|
@ -246,7 +245,7 @@ impl KeyValueDatabase {
|
|||
}
|
||||
))
|
||||
.exists();
|
||||
let rocksdb_exists = path.join("IDENTITY").exists();
|
||||
let rocksdb_exists = config.database.path.join("IDENTITY").exists();
|
||||
|
||||
let mut count = 0;
|
||||
|
||||
|
|
@ -298,7 +297,7 @@ impl KeyValueDatabase {
|
|||
pub(crate) fn load_or_create(config: &Config) -> Result<KeyValueDatabase> {
|
||||
Self::check_db_setup(config)?;
|
||||
|
||||
if !Path::new(&config.database.path).exists() {
|
||||
if !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 \
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ impl Engine {
|
|||
|
||||
impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||
fn open(config: &Config) -> Result<Self> {
|
||||
let path = Path::new(&config.database.path).join(format!(
|
||||
let path = config.database.path.join(format!(
|
||||
"{}.db",
|
||||
if config.conduit_compat {
|
||||
"conduit"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue