mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +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)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub(crate) struct DatabaseConfig {
|
pub(crate) struct DatabaseConfig {
|
||||||
pub(crate) backend: DatabaseBackend,
|
pub(crate) backend: DatabaseBackend,
|
||||||
pub(crate) path: String,
|
pub(crate) path: PathBuf,
|
||||||
#[serde(default = "default_db_cache_capacity_mb")]
|
#[serde(default = "default_db_cache_capacity_mb")]
|
||||||
pub(crate) cache_capacity_mb: f64,
|
pub(crate) cache_capacity_mb: f64,
|
||||||
#[cfg(feature = "rocksdb")]
|
#[cfg(feature = "rocksdb")]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use std::{
|
||||||
fs,
|
fs,
|
||||||
io::Write,
|
io::Write,
|
||||||
mem::size_of,
|
mem::size_of,
|
||||||
path::Path,
|
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -234,9 +233,9 @@ pub(crate) struct KeyValueDatabase {
|
||||||
|
|
||||||
impl KeyValueDatabase {
|
impl KeyValueDatabase {
|
||||||
fn check_db_setup(config: &Config) -> Result<()> {
|
fn check_db_setup(config: &Config) -> Result<()> {
|
||||||
let path = Path::new(&config.database.path);
|
let sqlite_exists = config
|
||||||
|
.database
|
||||||
let sqlite_exists = path
|
.path
|
||||||
.join(format!(
|
.join(format!(
|
||||||
"{}.db",
|
"{}.db",
|
||||||
if config.conduit_compat {
|
if config.conduit_compat {
|
||||||
|
|
@ -246,7 +245,7 @@ impl KeyValueDatabase {
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
.exists();
|
.exists();
|
||||||
let rocksdb_exists = path.join("IDENTITY").exists();
|
let rocksdb_exists = config.database.path.join("IDENTITY").exists();
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
|
|
@ -298,7 +297,7 @@ impl KeyValueDatabase {
|
||||||
pub(crate) fn load_or_create(config: &Config) -> Result<KeyValueDatabase> {
|
pub(crate) fn load_or_create(config: &Config) -> Result<KeyValueDatabase> {
|
||||||
Self::check_db_setup(config)?;
|
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(|_| {
|
fs::create_dir_all(&config.database.path).map_err(|_| {
|
||||||
Error::BadConfig(
|
Error::BadConfig(
|
||||||
"Database folder doesn't exists and couldn't be created \
|
"Database folder doesn't exists and couldn't be created \
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ impl Engine {
|
||||||
|
|
||||||
impl KeyValueDatabaseEngine for Arc<Engine> {
|
impl KeyValueDatabaseEngine for Arc<Engine> {
|
||||||
fn open(config: &Config) -> Result<Self> {
|
fn open(config: &Config) -> Result<Self> {
|
||||||
let path = Path::new(&config.database.path).join(format!(
|
let path = config.database.path.join(format!(
|
||||||
"{}.db",
|
"{}.db",
|
||||||
if config.conduit_compat {
|
if config.conduit_compat {
|
||||||
"conduit"
|
"conduit"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue