aboutsummaryrefslogtreecommitdiff
path: root/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'base/src')
-rw-r--r--base/src/database.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/base/src/database.rs b/base/src/database.rs
index 9d29adb..7755016 100644
--- a/base/src/database.rs
+++ b/base/src/database.rs
@@ -12,7 +12,13 @@ use jellycommon::{
use log::info;
use redb::{Database, TableDefinition};
use serde::{Deserialize, Serialize};
-use std::{borrow::Borrow, fs::create_dir_all, ops::Deref, path::Path, sync::RwLock};
+use std::{
+ borrow::Borrow,
+ fs::create_dir_all,
+ ops::Deref,
+ path::Path,
+ sync::{Arc, RwLock},
+};
use tantivy::{
directory::MmapDirectory,
schema::{Field, Schema, FAST, INDEXED, STORED, TEXT},
@@ -32,9 +38,10 @@ pub const T_NODE_EXTENDED: TableDefinition<&str, Ser<ExtendedNode>> =
pub const T_NODE_IMPORT: TableDefinition<&str, Ser<Vec<(Vec<usize>, Node)>>> =
TableDefinition::new("node-import");
+#[derive(Clone)]
pub struct DataAcid {
- pub inner: redb::Database,
- pub node_index: NodeIndex,
+ pub inner: Arc<redb::Database>,
+ pub node_index: Arc<NodeIndex>,
}
impl DataAcid {
@@ -45,8 +52,8 @@ impl DataAcid {
info!("opening node index...");
let ft_node = NodeIndex::new(path).context("in node index")?;
let r = Self {
- inner: db,
- node_index: ft_node,
+ inner: db.into(),
+ node_index: ft_node.into(),
};
{