aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/database.rs6
-rw-r--r--server/src/library.rs27
-rw-r--r--server/src/routes/mod.rs5
-rw-r--r--server/src/routes/ui/account/settings.rs10
4 files changed, 15 insertions, 33 deletions
diff --git a/server/src/database.rs b/server/src/database.rs
index b6e9ab9..bfb5d47 100644
--- a/server/src/database.rs
+++ b/server/src/database.rs
@@ -5,6 +5,7 @@
*/
use crate::{routes::ui::account::hash_password, CONF};
use anyhow::Context;
+use jellycommon::SeekIndex;
use log::info;
use serde::{Deserialize, Serialize};
use std::path::Path;
@@ -12,8 +13,11 @@ use typed_sled::Tree;
pub struct Database {
pub db: sled::Db,
+
pub users: Tree<String, User>,
pub invites: Tree<String, ()>,
+ pub items: Tree<String, Item>,
+ pub seek_index: Tree<(String, usize), SeekIndex>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -32,6 +36,8 @@ impl Database {
let r = Ok(Self {
users: Tree::open(&db, "users"),
invites: Tree::open(&db, "invites"),
+ items: Tree::open(&db, "items"),
+ seek_index: Tree::open(&db, "seek_index"),
db,
});
info!("ready");
diff --git a/server/src/library.rs b/server/src/library.rs
index ffd8b4a..8606a6e 100644
--- a/server/src/library.rs
+++ b/server/src/library.rs
@@ -16,33 +16,6 @@ use std::{
use crate::{routes::ui::node::AssetRole, CONF};
-pub struct Library {
- pub root: Arc<Node>,
- pub root_path: PathBuf,
-}
-
-#[derive(Debug, Clone)]
-pub enum Node {
- Directory(Arc<Directory>),
- Item(Arc<Item>),
-}
-
-#[derive(Debug, Clone)]
-pub struct Directory {
- pub lib_path: PathBuf,
- pub identifier: String,
- pub info: DirectoryInfo,
- pub children: Vec<Arc<Node>>,
-}
-
-#[derive(Debug, Clone)]
-pub struct Item {
- pub fs_path: PathBuf,
- pub lib_path: PathBuf,
- pub identifier: String,
- pub info: ItemInfo,
-}
-
impl Library {
pub fn open(path: &Path) -> anyhow::Result<Self> {
Ok(Self {
diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs
index 6f8109b..8d50c2e 100644
--- a/server/src/routes/mod.rs
+++ b/server/src/routes/mod.rs
@@ -4,7 +4,10 @@
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use crate::{database::Database, library::Library, routes::ui::error::MyResult, CONF};
-use api::{error::r_api_catch, r_api_account_login, r_api_node, r_api_assets_node, r_api_root, r_api_version};
+use api::{
+ error::r_api_catch, r_api_account_login, r_api_assets_node, r_api_node, r_api_root,
+ r_api_version,
+};
use jellyremuxer::RemuxerContext;
use rocket::{
catchers, config::SecretKey, fairing::AdHoc, fs::FileServer, get, http::Header, routes, Build,
diff --git a/server/src/routes/ui/account/settings.rs b/server/src/routes/ui/account/settings.rs
index e196b35..59b10b7 100644
--- a/server/src/routes/ui/account/settings.rs
+++ b/server/src/routes/ui/account/settings.rs
@@ -3,11 +3,6 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
-use std::ops::Range;
-use rocket::{
- form::{self, validate::len, Contextual, Form},
- get, post, FromForm, State,
-};
use super::{format_form_error, hash_password};
use crate::{
database::Database,
@@ -18,6 +13,11 @@ use crate::{
},
uri,
};
+use rocket::{
+ form::{self, validate::len, Contextual, Form},
+ get, post, FromForm, State,
+};
+use std::ops::Range;
#[derive(FromForm)]
pub struct SettingsForm {