aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/database.rs5
-rw-r--r--server/src/main.rs2
-rw-r--r--server/src/routes/api/error.rs4
-rw-r--r--server/src/routes/stream.rs5
-rw-r--r--server/src/routes/ui/account/session.rs3
-rw-r--r--server/src/routes/ui/player.rs5
6 files changed, 14 insertions, 10 deletions
diff --git a/server/src/database.rs b/server/src/database.rs
index a4e5b85..00ce193 100644
--- a/server/src/database.rs
+++ b/server/src/database.rs
@@ -1,9 +1,10 @@
+use std::path::Path;
+
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
-use std::path::PathBuf;
use anyhow::Context;
use log::info;
use serde::{Deserialize, Serialize};
@@ -24,7 +25,7 @@ pub struct User {
}
impl Database {
- pub fn open(path: &PathBuf) -> Result<Self, anyhow::Error> {
+ pub fn open(path: &Path) -> Result<Self, anyhow::Error> {
info!("opening database… (takes O(n) time sadly)");
let db = sled::open(path).context("opening database")?;
info!("ready");
diff --git a/server/src/main.rs b/server/src/main.rs
index 6baaa2a..d8a7441 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -3,8 +3,6 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
-#![feature(box_syntax)]
-
use config::{load_global_config, GlobalConfig};
use database::{Database, User};
use jellyremuxer::RemuxerContext;
diff --git a/server/src/routes/api/error.rs b/server/src/routes/api/error.rs
index 9630f94..c4ca989 100644
--- a/server/src/routes/api/error.rs
+++ b/server/src/routes/api/error.rs
@@ -2,8 +2,10 @@
use crate::routes::ui::error::MyError;
use rocket::{
+ catch,
+ http::Status,
response::{self, Responder},
- Request, http::Status, catch,
+ Request,
};
use serde_json::{json, Value};
use std::fmt::Display;
diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs
index 749077c..af81d64 100644
--- a/server/src/routes/stream.rs
+++ b/server/src/routes/stream.rs
@@ -52,7 +52,7 @@ pub fn r_stream(
.map(|r| r.to_cr_hv())
.unwrap_or(format!("none"))
);
- let (a, b) = duplex(1024);
+ let (a, b) = duplex(4096);
let path = path.to_str().unwrap().to_string();
let item = library
.nested(&path)
@@ -68,8 +68,7 @@ pub fn r_stream(
let urange = match &range {
Some(r) => {
- // TODO this can crash
- let r = &r.0[0];
+ let r = r.0.get(0).unwrap_or(&(None..None));
r.start.unwrap_or(0)..r.end.unwrap_or(isize::MAX as usize)
}
None => 0..(isize::MAX as usize),
diff --git a/server/src/routes/ui/account/session.rs b/server/src/routes/ui/account/session.rs
index 6795c06..c41c968 100644
--- a/server/src/routes/ui/account/session.rs
+++ b/server/src/routes/ui/account/session.rs
@@ -5,7 +5,8 @@
*/
use crate::{
database::{Database, User},
- routes::ui::error::MyError, CONF,
+ routes::ui::error::MyError,
+ CONF,
};
use anyhow::anyhow;
use chrono::{DateTime, Duration, Utc};
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index 20b451f..ca3ce14 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -13,7 +13,10 @@ use crate::{
};
use jellycommon::SourceTrackKind;
use rocket::{get, FromForm, State};
-use std::{path::{PathBuf, Path}, sync::Arc};
+use std::{
+ path::{Path, PathBuf},
+ sync::Arc,
+};
pub fn player_uri(path: &Path) -> String {
format!("/player/{}", path.to_str().unwrap())