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