sqlite: Remove unused path field

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille
2024-08-23 09:49:43 +02:00
committed by Benjamin Bouvier
parent 154f86aa20
commit 25e406f669
3 changed files with 9 additions and 30 deletions

View File

@@ -16,7 +16,7 @@ use std::{
borrow::Cow,
collections::HashMap,
fmt,
path::{Path, PathBuf},
path::Path,
sync::{Arc, RwLock},
};
@@ -55,7 +55,6 @@ use crate::{
#[derive(Clone)]
pub struct SqliteCryptoStore {
store_cipher: Option<Arc<StoreCipher>>,
path: Option<PathBuf>,
pool: SqlitePool,
// DB values cached in memory
@@ -66,11 +65,7 @@ pub struct SqliteCryptoStore {
#[cfg(not(tarpaulin_include))]
impl fmt::Debug for SqliteCryptoStore {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(path) = &self.path {
f.debug_struct("SqliteCryptoStore").field("path", &path).finish()
} else {
f.debug_struct("SqliteCryptoStore").field("path", &"memory store").finish()
}
f.debug_struct("SqliteCryptoStore").finish_non_exhaustive()
}
}
@@ -105,7 +100,6 @@ impl SqliteCryptoStore {
Ok(SqliteCryptoStore {
store_cipher,
path: None,
pool,
static_account: Arc::new(RwLock::new(None)),
save_changes_lock: Default::default(),

View File

@@ -1,9 +1,4 @@
use std::{
borrow::Cow,
fmt,
path::{Path, PathBuf},
sync::Arc,
};
use std::{borrow::Cow, fmt, path::Path, sync::Arc};
use async_trait::async_trait;
use deadpool_sqlite::{Object as SqliteConn, Pool as SqlitePool, Runtime};
@@ -39,18 +34,13 @@ const DATABASE_VERSION: u8 = 1;
#[derive(Clone)]
pub struct SqliteEventCacheStore {
store_cipher: Option<Arc<StoreCipher>>,
path: Option<PathBuf>,
pool: SqlitePool,
}
#[cfg(not(tarpaulin_include))]
impl fmt::Debug for SqliteEventCacheStore {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(path) = &self.path {
f.debug_struct("SqliteEventCacheStore").field("path", &path).finish()
} else {
f.debug_struct("SqliteEventCacheStore").field("path", &"memory store").finish()
}
f.debug_struct("SqliteEventCacheStore").finish_non_exhaustive()
}
}
@@ -84,7 +74,7 @@ impl SqliteEventCacheStore {
Some(p) => Some(Arc::new(get_or_create_store_cipher(p, &conn).await?)),
None => None,
};
let this = Self { store_cipher, path: None, pool };
let this = Self { store_cipher, pool };
this.run_migrations(&conn, version, None).await?;
Ok(this)

View File

@@ -2,7 +2,7 @@ use std::{
borrow::Cow,
collections::{BTreeMap, BTreeSet},
fmt, iter,
path::{Path, PathBuf},
path::Path,
sync::Arc,
};
@@ -72,18 +72,13 @@ const DATABASE_VERSION: u8 = 7;
#[derive(Clone)]
pub struct SqliteStateStore {
store_cipher: Option<Arc<StoreCipher>>,
path: Option<PathBuf>,
pool: SqlitePool,
}
#[cfg(not(tarpaulin_include))]
impl fmt::Debug for SqliteStateStore {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(path) = &self.path {
f.debug_struct("SqliteStateStore").field("path", &path).finish()
} else {
f.debug_struct("SqliteStateStore").field("path", &"memory store").finish()
}
f.debug_struct("SqliteStateStore").finish_non_exhaustive()
}
}
@@ -117,7 +112,7 @@ impl SqliteStateStore {
Some(p) => Some(Arc::new(get_or_create_store_cipher(p, &conn).await?)),
None => None,
};
let this = Self { store_cipher, path: None, pool };
let this = Self { store_cipher, pool };
this.run_migrations(&conn, version, None).await?;
Ok(this)
@@ -2023,7 +2018,7 @@ mod migration_tests {
init(&conn).await?;
let store_cipher = Some(Arc::new(get_or_create_store_cipher(SECRET, &conn).await.unwrap()));
let this = SqliteStateStore { store_cipher, path: None, pool };
let this = SqliteStateStore { store_cipher, pool };
this.run_migrations(&conn, 1, Some(version)).await?;
Ok(this)