.
This commit is contained in:
parent
25f64ec690
commit
ff1f474324
1 changed files with 3271 additions and 2003 deletions
|
|
@ -16,6 +16,7 @@ use tokio::time::Instant;
|
|||
|
||||
pub mod models;
|
||||
|
||||
mod history;
|
||||
mod mutations;
|
||||
mod queries;
|
||||
|
||||
|
|
@ -83,7 +84,7 @@ impl Database {
|
|||
Ok(database)
|
||||
}
|
||||
|
||||
fn database_path(config: &DatabaseConfig, vault: &str) -> PathBuf {
|
||||
fn get_database_path(config: &DatabaseConfig, vault: &str) -> PathBuf {
|
||||
// Hash the normalized vault name into a fixed-length ASCII filename so
|
||||
// filesystem case/Unicode aliasing (e.g. composed vs. decomposed é on
|
||||
// macOS) cannot make separately authorized vaults share a database.
|
||||
|
|
@ -159,7 +160,7 @@ impl Database {
|
|||
let vault = normalize_string(vault);
|
||||
validate_vault_id(&vault)?;
|
||||
|
||||
if let Some(pool) = self.existing_pool(&vault).await {
|
||||
if let Some(pool) = self.find_cached_pool(&vault).await {
|
||||
return Ok(pool);
|
||||
}
|
||||
|
||||
|
|
@ -170,11 +171,11 @@ impl Database {
|
|||
|
||||
let _opening = opening.lock().await;
|
||||
|
||||
if let Some(pool) = self.existing_pool(&vault).await {
|
||||
if let Some(pool) = self.find_cached_pool(&vault).await {
|
||||
return Ok(pool);
|
||||
}
|
||||
|
||||
let file_name = Self::database_path(&self.config, &vault);
|
||||
let file_name = Self::get_database_path(&self.config, &vault);
|
||||
let pool = Self::open_database(&self.config, &file_name).await?;
|
||||
|
||||
self.connection_pools.lock().await.insert(
|
||||
|
|
@ -187,7 +188,7 @@ impl Database {
|
|||
Ok(pool)
|
||||
}
|
||||
|
||||
async fn existing_pool(&self, vault: &VaultId) -> Option<Pool<Sqlite>> {
|
||||
async fn find_cached_pool(&self, vault: &VaultId) -> Option<Pool<Sqlite>> {
|
||||
self.connection_pools
|
||||
.lock()
|
||||
.await
|
||||
|
|
|
|||
Loading…
Reference in a new issue