diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-29 16:07:58 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-29 16:07:58 +0100 |
commit | e7ba3274e27fad755f15465581f5b403c82ab4d2 (patch) | |
tree | f2d693c61786ee6ed027636393fd75f086bd77e8 /base | |
parent | 5ac3f397b4a28b7bf8b399e73ad0d29e3da45ab0 (diff) | |
download | jellything-e7ba3274e27fad755f15465581f5b403c82ab4d2.tar jellything-e7ba3274e27fad755f15465581f5b403c82ab4d2.tar.bz2 jellything-e7ba3274e27fad755f15465581f5b403c82ab4d2.tar.zst |
prepare database refactor
Diffstat (limited to 'base')
-rw-r--r-- | base/Cargo.toml | 10 | ||||
-rw-r--r-- | base/src/database.rs | 21 | ||||
-rw-r--r-- | base/src/permission.rs | 6 |
3 files changed, 16 insertions, 21 deletions
diff --git a/base/Cargo.toml b/base/Cargo.toml index be32dce..b9e47de 100644 --- a/base/Cargo.toml +++ b/base/Cargo.toml @@ -6,18 +6,18 @@ edition = "2021" [dependencies] jellycommon = { path = "../common" } jellyclient = { path = "../client" } -serde = { version = "1.0.214", features = ["derive"] } +serde = { version = "1.0.217", features = ["derive"] } serde_yaml = "0.9.34" log = { workspace = true } sha2 = "0.10.8" base64 = "0.22.1" tokio = { workspace = true } -anyhow = "1.0.92" +anyhow = "1.0.95" bincode = "2.0.0-rc.3" -rand = "0.8.5" -redb = "2.2.0" +rand = "0.9.0" +redb = "2.4.0" tantivy = "0.22.0" -serde_json = "1.0.132" +serde_json = "1.0.138" aes-gcm-siv = "0.11.1" [features] diff --git a/base/src/database.rs b/base/src/database.rs index e57ea3e..a6bcdf7 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -7,7 +7,7 @@ use anyhow::Context; use bincode::{Decode, Encode}; use jellycommon::{ user::{NodeUserData, User}, - ExtendedNode, Node, + Node, }; use log::info; use redb::{Database, TableDefinition}; @@ -33,11 +33,6 @@ pub const T_USER_NODE: TableDefinition<(&str, &str), Ser<NodeUserData>> = TableDefinition::new("user_node"); pub const T_INVITE: TableDefinition<&str, Ser<()>> = TableDefinition::new("invite"); pub const T_NODE: TableDefinition<&str, Ser<Node>> = TableDefinition::new("node"); -pub const T_NODE_EXTENDED: TableDefinition<&str, Ser<ExtendedNode>> = - TableDefinition::new("node-ext"); -#[allow(clippy::type_complexity)] -pub const T_NODE_IMPORT: TableDefinition<&str, Ser<Vec<(Vec<usize>, Node)>>> = - TableDefinition::new("node-import"); #[derive(Clone)] pub struct DataAcid { @@ -64,8 +59,6 @@ impl DataAcid { drop(txn.open_table(T_USER)?); drop(txn.open_table(T_USER_NODE)?); drop(txn.open_table(T_NODE)?); - drop(txn.open_table(T_NODE_IMPORT)?); - drop(txn.open_table(T_NODE_EXTENDED)?); txn.commit()?; } @@ -205,10 +198,12 @@ where pub struct Ser<T>(pub T); #[cfg(not(feature = "db_json"))] impl<T: Encode + Decode + std::fmt::Debug> redb::Value for Ser<T> { - type SelfType<'a> = Ser<T> + type SelfType<'a> + = Ser<T> where Self: 'a; - type AsBytes<'a> = Vec<u8> + type AsBytes<'a> + = Vec<u8> where Self: 'a; @@ -243,10 +238,12 @@ impl<T: Encode + Decode + std::fmt::Debug> redb::Value for Ser<T> { pub struct Ser<T>(pub T); #[cfg(feature = "db_json")] impl<T: Serialize + for<'a> Deserialize<'a> + std::fmt::Debug> redb::Value for Ser<T> { - type SelfType<'a> = Ser<T> + type SelfType<'a> + = Ser<T> where Self: 'a; - type AsBytes<'a> = Vec<u8> + type AsBytes<'a> + = Vec<u8> where Self: 'a; diff --git a/base/src/permission.rs b/base/src/permission.rs index 358202f..11668a2 100644 --- a/base/src/permission.rs +++ b/base/src/permission.rs @@ -51,12 +51,10 @@ impl NodePermissionExt for Option<Node> { } } fn check_node_permission(perms: &PermissionSet, node: &Node) -> bool { - if let Some(v) = - perms.check_explicit(&UserPermission::AccessNode(node.public.id.clone().unwrap())) - { + if let Some(v) = perms.check_explicit(&UserPermission::AccessNode(node.id.clone().unwrap())) { v } else { - for com in node.public.path.clone().into_iter().rev() { + for com in node.parents.clone().into_iter() { if let Some(v) = perms.check_explicit(&UserPermission::AccessNode(com.to_owned())) { return v; } |