mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
remove check_db_setup
This won't be feasible if the sqlite database file name changes or if support for out-of-process databases is added.
This commit is contained in:
parent
a061afa431
commit
989cad2715
1 changed files with 0 additions and 57 deletions
|
|
@ -233,61 +233,6 @@ pub(crate) struct KeyValueDatabase {
|
|||
}
|
||||
|
||||
impl KeyValueDatabase {
|
||||
fn check_db_setup(config: &Config) -> Result<()> {
|
||||
let path = Path::new(&config.database.path);
|
||||
|
||||
let sqlite_exists = path
|
||||
.join(format!(
|
||||
"{}.db",
|
||||
if config.conduit_compat {
|
||||
"conduit"
|
||||
} else {
|
||||
"grapevine"
|
||||
}
|
||||
))
|
||||
.exists();
|
||||
let rocksdb_exists = path.join("IDENTITY").exists();
|
||||
|
||||
let mut count = 0;
|
||||
|
||||
if sqlite_exists {
|
||||
count += 1;
|
||||
}
|
||||
|
||||
if rocksdb_exists {
|
||||
count += 1;
|
||||
}
|
||||
|
||||
if count > 1 {
|
||||
warn!("Multiple databases at database_path detected");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let (backend_is_rocksdb, backend_is_sqlite): (bool, bool) =
|
||||
match config.database.backend {
|
||||
#[cfg(feature = "rocksdb")]
|
||||
DatabaseBackend::Rocksdb => (true, false),
|
||||
#[cfg(feature = "sqlite")]
|
||||
DatabaseBackend::Sqlite => (false, true),
|
||||
};
|
||||
|
||||
if sqlite_exists && !backend_is_sqlite {
|
||||
return Err(Error::bad_config(
|
||||
"Found sqlite at database_path, but is not specified in \
|
||||
config.",
|
||||
));
|
||||
}
|
||||
|
||||
if rocksdb_exists && !backend_is_rocksdb {
|
||||
return Err(Error::bad_config(
|
||||
"Found rocksdb at database_path, but is not specified in \
|
||||
config.",
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn load_or_create_engine(
|
||||
config: &Config,
|
||||
) -> Result<Arc<dyn KeyValueDatabaseEngine>> {
|
||||
|
|
@ -296,8 +241,6 @@ impl KeyValueDatabase {
|
|||
"Compiled without support for any databases",
|
||||
));
|
||||
|
||||
Self::check_db_setup(config)?;
|
||||
|
||||
if !Path::new(&config.database.path).exists() {
|
||||
fs::create_dir_all(&config.database.path).map_err(|_| {
|
||||
Error::BadConfig(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue