From e7ba3274e27fad755f15465581f5b403c82ab4d2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 29 Jan 2025 16:07:58 +0100 Subject: prepare database refactor --- base/src/database.rs | 21 +++++++++------------ base/src/permission.rs | 6 ++---- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'base/src') 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> = TableDefinition::new("user_node"); pub const T_INVITE: TableDefinition<&str, Ser<()>> = TableDefinition::new("invite"); pub const T_NODE: TableDefinition<&str, Ser> = TableDefinition::new("node"); -pub const T_NODE_EXTENDED: TableDefinition<&str, Ser> = - TableDefinition::new("node-ext"); -#[allow(clippy::type_complexity)] -pub const T_NODE_IMPORT: TableDefinition<&str, Ser, 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(pub T); #[cfg(not(feature = "db_json"))] impl redb::Value for Ser { - type SelfType<'a> = Ser + type SelfType<'a> + = Ser where Self: 'a; - type AsBytes<'a> = Vec + type AsBytes<'a> + = Vec where Self: 'a; @@ -243,10 +238,12 @@ impl redb::Value for Ser { pub struct Ser(pub T); #[cfg(feature = "db_json")] impl Deserialize<'a> + std::fmt::Debug> redb::Value for Ser { - type SelfType<'a> = Ser + type SelfType<'a> + = Ser where Self: 'a; - type AsBytes<'a> = Vec + type AsBytes<'a> + = Vec 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 { } } 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; } -- cgit v1.2.3-70-g09d2