fix: reenable locks
parent
0ced93adcc
commit
54897f1468
|
@ -64,6 +64,7 @@ impl Drop for PragmaSynchronousGuard<'_> {
|
||||||
pub struct FsStore {
|
pub struct FsStore {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
manager: ConnectionManager<SqliteConnection>,
|
manager: ConnectionManager<SqliteConnection>,
|
||||||
|
lock: Arc<RwLock<()>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FsStore {
|
impl FsStore {
|
||||||
|
@ -97,7 +98,13 @@ impl FsStore {
|
||||||
"#,
|
"#,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(FsStore { path, manager })
|
let lock = Arc::new(RwLock::new(()));
|
||||||
|
|
||||||
|
Ok(FsStore {
|
||||||
|
path,
|
||||||
|
manager,
|
||||||
|
lock,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rescan_vault<D: Borrow<UpEndDatabase>>(
|
fn rescan_vault<D: Borrow<UpEndDatabase>>(
|
||||||
|
@ -490,7 +497,7 @@ impl FsStore {
|
||||||
Address::Hash(Hash((&file.hash).clone()))
|
Address::Hash(Hash((&file.hash).clone()))
|
||||||
);
|
);
|
||||||
|
|
||||||
// let _lock = self.lock.write().unwrap();
|
let _lock = self.lock.write().unwrap();
|
||||||
let conn = self.manager.connect()?;
|
let conn = self.manager.connect()?;
|
||||||
|
|
||||||
diesel::insert_into(files::table)
|
diesel::insert_into(files::table)
|
||||||
|
@ -509,7 +516,7 @@ impl FsStore {
|
||||||
fn retrieve_file(&self, obj_hash: &Hash) -> Result<Vec<db::OutFile>> {
|
fn retrieve_file(&self, obj_hash: &Hash) -> Result<Vec<db::OutFile>> {
|
||||||
use self::db::files::dsl::*;
|
use self::db::files::dsl::*;
|
||||||
|
|
||||||
// let _lock = self.lock.read().unwrap();
|
let _lock = self.lock.read().unwrap();
|
||||||
let conn = self.manager.connect()?;
|
let conn = self.manager.connect()?;
|
||||||
|
|
||||||
let matches = files
|
let matches = files
|
||||||
|
@ -536,7 +543,7 @@ impl FsStore {
|
||||||
fn retrieve_all_files(&self) -> Result<Vec<db::File>> {
|
fn retrieve_all_files(&self) -> Result<Vec<db::File>> {
|
||||||
use self::db::files::dsl::*;
|
use self::db::files::dsl::*;
|
||||||
|
|
||||||
// let _lock = self.lock.read().unwrap();
|
let _lock = self.lock.read().unwrap();
|
||||||
let conn = self.manager.connect()?;
|
let conn = self.manager.connect()?;
|
||||||
|
|
||||||
let matches = files.load::<db::File>(&conn)?;
|
let matches = files.load::<db::File>(&conn)?;
|
||||||
|
@ -547,7 +554,7 @@ impl FsStore {
|
||||||
use self::db::files::dsl::*;
|
use self::db::files::dsl::*;
|
||||||
debug!("Setting file ID {}'s mtime = {:?}", file_id, m_time);
|
debug!("Setting file ID {}'s mtime = {:?}", file_id, m_time);
|
||||||
|
|
||||||
// let _lock = self.lock.write().unwrap();
|
let _lock = self.lock.write().unwrap();
|
||||||
let conn = self.manager.connect()?;
|
let conn = self.manager.connect()?;
|
||||||
|
|
||||||
Ok(diesel::update(files.filter(id.eq(file_id)))
|
Ok(diesel::update(files.filter(id.eq(file_id)))
|
||||||
|
@ -559,7 +566,7 @@ impl FsStore {
|
||||||
use self::db::files::dsl::*;
|
use self::db::files::dsl::*;
|
||||||
debug!("Setting file ID {} to valid = {}", file_id, is_valid);
|
debug!("Setting file ID {} to valid = {}", file_id, is_valid);
|
||||||
|
|
||||||
// let _lock = self.lock.write().unwrap();
|
let _lock = self.lock.write().unwrap();
|
||||||
let conn = self.manager.connect()?;
|
let conn = self.manager.connect()?;
|
||||||
|
|
||||||
Ok(diesel::update(files.filter(id.eq(file_id)))
|
Ok(diesel::update(files.filter(id.eq(file_id)))
|
||||||
|
@ -679,7 +686,7 @@ mod test {
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
use tracing_subscriber::filter::{EnvFilter};
|
use tracing_subscriber::filter::EnvFilter;
|
||||||
|
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue