diff options
-rw-r--r-- | common/src/impl.rs | 2 | ||||
-rw-r--r-- | common/src/lib.rs | 5 | ||||
-rw-r--r-- | ebml_derive/src/lib.rs | 8 | ||||
-rw-r--r-- | matroska/src/bin/experiment.rs | 17 | ||||
-rw-r--r-- | matroska/src/bin/mkvdump.rs | 2 | ||||
-rw-r--r-- | matroska/src/read.rs | 2 | ||||
-rw-r--r-- | matroska/src/unflatten.rs | 4 | ||||
-rw-r--r-- | matroska/src/write.rs | 21 | ||||
-rw-r--r-- | remuxer/src/import/mod.rs | 22 | ||||
-rw-r--r-- | remuxer/src/lib.rs | 67 | ||||
-rw-r--r-- | server/src/library.rs | 13 | ||||
-rw-r--r-- | server/src/main.rs | 4 | ||||
-rw-r--r-- | server/src/routes/stream.rs | 14 | ||||
-rw-r--r-- | server/src/routes/ui/account/session.rs | 3 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 5 | ||||
-rw-r--r-- | server/src/routes/ui/player.rs | 6 |
16 files changed, 109 insertions, 86 deletions
diff --git a/common/src/impl.rs b/common/src/impl.rs index 7be6911..a7f8c6a 100644 --- a/common/src/impl.rs +++ b/common/src/impl.rs @@ -21,7 +21,7 @@ impl std::fmt::Display for SourceTrack { sample_rate, bit_depth, } => format!("Audio: {channels}ch {sample_rate}Hz {bit_depth}bits "), - SourceTrackKind::Subtitles => format!("Subtitles: "), + SourceTrackKind::Subtitles => "Subtitles: ".to_string(), }; f.write_fmt(format_args!( "{} {:?} {} ({})", diff --git a/common/src/lib.rs b/common/src/lib.rs index 08517c3..28ce5a8 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -2,10 +2,7 @@ pub mod r#impl; use bincode::{Decode, Encode}; use serde::{Deserialize, Serialize}; -use std::{ - collections::{BTreeMap, HashMap}, - path::PathBuf, -}; +use std::{collections::BTreeMap, path::PathBuf}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DirectoryInfo { diff --git a/ebml_derive/src/lib.rs b/ebml_derive/src/lib.rs index 2c0379f..18a43a9 100644 --- a/ebml_derive/src/lib.rs +++ b/ebml_derive/src/lib.rs @@ -35,7 +35,7 @@ pub fn define_ebml(ts: TokenStream) -> TokenStream { "Float" => quote!((f64)), "Utf8" => quote!((String)), "Binary" => quote!((Vec<u8>)), - _ => panic!("unsupported type {}", r#type), + _ => panic!("unsupported type {type}"), }, }) .expect("parse type"), @@ -69,7 +69,7 @@ pub fn define_ebml(ts: TokenStream) -> TokenStream { |Tag { id, name, r#type, .. }| { - if let Some(_) = r#type { + if r#type.is_some() { Some(quote! { #id => Self::#name(crate::ReadValue::from_buf(data)?) }) } else { None @@ -79,7 +79,7 @@ pub fn define_ebml(ts: TokenStream) -> TokenStream { .collect::<Vec<_>>(); let write_match = tags .iter() - .filter_map(|Tag { name, .. }| Some(quote! { Self::#name(v) => v.write_to(w) })) + .map(|Tag { name, .. }| quote! { Self::#name(v) => v.write_to(w) }) .collect::<Vec<_>>(); let cons_master_match = tags .iter() @@ -87,7 +87,7 @@ pub fn define_ebml(ts: TokenStream) -> TokenStream { |Tag { id, name, r#type, .. }| { - if let None = r#type { + if r#type.is_none() { Some(quote! { #id => Self::#name(kind) }) } else { None diff --git a/matroska/src/bin/experiment.rs b/matroska/src/bin/experiment.rs index 7787f4f..fe3096e 100644 --- a/matroska/src/bin/experiment.rs +++ b/matroska/src/bin/experiment.rs @@ -3,7 +3,9 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2023 metamuffin <metamuffin.org> */ -use jellymatroska::{matroska::MatroskaTag, read::EbmlReader, write::EbmlWriter, unflatten::IterWithPos}; +use jellymatroska::{ + matroska::MatroskaTag, read::EbmlReader, unflatten::IterWithPos, write::EbmlWriter, +}; use std::{ fs::File, io::{stdout, BufReader, BufWriter}, @@ -11,7 +13,7 @@ use std::{ fn main() -> anyhow::Result<()> { env_logger::init_from_env("LOG"); - let path = std::env::args().skip(1).next().unwrap(); + let path = std::env::args().nth(1).unwrap(); let mut r = EbmlReader::new(BufReader::new(File::open(path)?)); let mut w = EbmlWriter::new(BufWriter::new(stdout()), 0); @@ -23,15 +25,10 @@ fn main() -> anyhow::Result<()> { while let Some(tag) = r.next() { let tag = tag?; - // println!("{} {tag:?}", r.position); - match tag { - tag => { - if MatroskaTag::is_master(tag.id())? { - eprintln!("{tag:?}"); - } - w.write_tag(&tag)?; - } + if MatroskaTag::is_master(tag.id())? { + eprintln!("{tag:?}"); } + w.write_tag(&tag)?; } Ok(()) } diff --git a/matroska/src/bin/mkvdump.rs b/matroska/src/bin/mkvdump.rs index ba05c19..ead6ece 100644 --- a/matroska/src/bin/mkvdump.rs +++ b/matroska/src/bin/mkvdump.rs @@ -8,7 +8,7 @@ use std::{fs::File, io::BufReader}; fn main() -> anyhow::Result<()> { env_logger::init_from_env("LOG"); - let path = std::env::args().skip(1).next().unwrap(); + let path = std::env::args().nth(1).unwrap(); let mut r = EbmlReader::new(BufReader::new(File::open(path)?)); while let Some(tag) = r.next() { diff --git a/matroska/src/read.rs b/matroska/src/read.rs index c99f304..e2bf15c 100644 --- a/matroska/src/read.rs +++ b/matroska/src/read.rs @@ -87,7 +87,7 @@ impl EbmlReader { Ok(EbmlSize::from_vint(self.read_vint_len()?)) } pub fn read_stuff(&mut self) -> Result<()> { - while let Some(e) = self.stack.last().map(|e| *e) { + while let Some(e) = self.stack.last().copied() { if let Some(end) = e.end { if self.position >= end { if self.position != end { diff --git a/matroska/src/unflatten.rs b/matroska/src/unflatten.rs index 663eebc..57fd35b 100644 --- a/matroska/src/unflatten.rs +++ b/matroska/src/unflatten.rs @@ -46,7 +46,7 @@ impl<'a> Unflatten<'a> { self.inner.position() } - pub fn next(&mut self) -> Option<Result<Unflat>> { + pub fn n(&mut self) -> Option<Result<Unflat>> { if self.stop { return None; } @@ -84,6 +84,6 @@ impl<'a> Unflatten<'a> { impl Drop for Unflatten<'_> { fn drop(&mut self) { - while let Some(_) = self.next() {} + while self.n().is_some() {} } } diff --git a/matroska/src/write.rs b/matroska/src/write.rs index 8c1e7bb..6f8aad4 100644 --- a/matroska/src/write.rs +++ b/matroska/src/write.rs @@ -82,7 +82,7 @@ impl EbmlWriter { let mut bytes = i.to_be_bytes(); let trunc = &mut bytes[(8 - len)..]; trunc[0] |= 1 << (8 - len); - self.write(&trunc) + self.write(trunc) } } @@ -103,7 +103,7 @@ pub trait WriteValue { impl WriteValue for i64 { fn write_to(&self, w: &mut Vec<u8>) -> Result<()> { - Ok(match 64 - self.leading_zeros() { + match 64 - self.leading_zeros() { x if x <= 8 => { w.push(0x81); w.extend_from_slice(&(*self as i8).to_be_bytes()); @@ -120,12 +120,13 @@ impl WriteValue for i64 { w.push(0x88); w.extend_from_slice(&self.to_be_bytes()); } - }) + }; + Ok(()) } } impl WriteValue for u64 { fn write_to(&self, w: &mut Vec<u8>) -> Result<()> { - Ok(match 64 - self.leading_zeros() { + match 64 - self.leading_zeros() { x if x <= 8 => { w.push(0x81); w.extend_from_slice(&(*self as u8).to_be_bytes()); @@ -142,7 +143,8 @@ impl WriteValue for u64 { w.push(0x88); w.extend_from_slice(&self.to_be_bytes()); } - }) + }; + Ok(()) } } impl WriteValue for f64 { @@ -155,7 +157,7 @@ impl WriteValue for f64 { impl WriteValue for Vec<u8> { fn write_to(&self, w: &mut Vec<u8>) -> Result<(), anyhow::Error> { write_vint(w, self.len() as u64)?; - w.extend_from_slice(&self); + w.extend_from_slice(self); Ok(()) } } @@ -181,7 +183,10 @@ impl WriteValue for Master { fn write_to(&self, w: &mut Vec<u8>) -> Result<()> { match self { Master::Start => EbmlSize::Unknown.write_to(w), - Master::End => Ok(w.clear()), + Master::End => { + w.clear(); + Ok(()) + } Master::Collected(c) => { let mut ib = vec![]; for c in c { @@ -203,6 +208,6 @@ pub fn write_vint(w: &mut Vec<u8>, i: u64) -> Result<()> { let mut bytes = i.to_be_bytes(); let trunc = &mut bytes[(8 - len)..]; trunc[0] |= 1 << (8 - len); - w.extend_from_slice(&trunc); + w.extend_from_slice(trunc); Ok(()) } diff --git a/remuxer/src/import/mod.rs b/remuxer/src/import/mod.rs index 1ceca1e..c3dbf49 100644 --- a/remuxer/src/import/mod.rs +++ b/remuxer/src/import/mod.rs @@ -26,7 +26,7 @@ pub fn import_read(path: &PathBuf, input: &mut EbmlReader, iteminfo: &mut ItemIn match item { MatroskaTag::Ebml(_) => { let mut iter = Unflatten::new_with_end(input, item); - while let Some(Ok(Unflat { children: _, item })) = iter.next() { + while let Some(Ok(Unflat { children: _, item })) = iter.n() { match item { MatroskaTag::DocType(t) => { if !matches!(t.as_str(), "matroska" | "webm") { @@ -58,12 +58,12 @@ fn import_read_segment( let (mut timestamp_scale, mut duration) = (None, None); let mut seek_index = HashMap::new(); - while let Some(Ok(Unflat { children, item })) = children.next() { + while let Some(Ok(Unflat { children, item })) = children.n() { match item { MatroskaTag::SeekHead(_) => {} MatroskaTag::Info(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { children: _, item })) = children.next() { + while let Some(Ok(Unflat { children: _, item })) = children.n() { match item { MatroskaTag::TimestampScale(v) => timestamp_scale = Some(v), MatroskaTag::Duration(v) => duration = Some(v), @@ -76,7 +76,7 @@ fn import_read_segment( MatroskaTag::Chapters(_) => {} MatroskaTag::Tracks(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { children, item })) = children.next() { + while let Some(Ok(Unflat { children, item })) = children.n() { match item { MatroskaTag::TrackEntry(_) => { let mut children = children.unwrap(); @@ -98,7 +98,7 @@ fn import_read_segment( None, None, None, None, None, None, None, None, None, None, None, None, None, ); - while let Some(Ok(Unflat { children, item })) = children.next() { + while let Some(Ok(Unflat { children, item })) = children.n() { match item { MatroskaTag::CodecID(b) => codec = Some(b), MatroskaTag::Language(v) => language = Some(v), @@ -109,7 +109,7 @@ fn import_read_segment( MatroskaTag::DefaultDuration(v) => default_duration = Some(v), MatroskaTag::Audio(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { item, .. })) = children.next() { + while let Some(Ok(Unflat { item, .. })) = children.n() { match item { MatroskaTag::Channels(v) => { channels = Some(v as usize) @@ -124,7 +124,7 @@ fn import_read_segment( } MatroskaTag::Video(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { item, .. })) = children.next() { + while let Some(Ok(Unflat { item, .. })) = children.n() { match item { MatroskaTag::PixelWidth(v) => width = Some(v), MatroskaTag::PixelHeight(v) => height = Some(v), @@ -174,14 +174,14 @@ fn import_read_segment( let mut children = children.unwrap(); let mut pts = 0; - while let Some(Ok(Unflat { children, item })) = children.next() { + while let Some(Ok(Unflat { children, item })) = children.n() { match item { MatroskaTag::Timestamp(ts) => pts = ts, MatroskaTag::BlockGroup(_) => { debug!("group"); let mut children = children.unwrap(); let pos = children.position(); - while let Some(Ok(Unflat { children: _, item })) = children.next() { + while let Some(Ok(Unflat { children: _, item })) = children.n() { match item { MatroskaTag::Block(ref buf) => { let block = Block::parse(buf)?; @@ -231,12 +231,12 @@ fn import_read_segment( for (tn, index) in seek_index { bincode::encode_into_std_write( index, - &mut File::create(path.with_extension(&format!("si.{}", tn)))?, + &mut File::create(path.with_extension(&format!("si.{tn}")))?, bincode::config::standard(), )?; } iteminfo.duration = - (duration.unwrap() * timestamp_scale.unwrap() as f64) as f64 / 1_000_000_000 as f64; + (duration.unwrap() * timestamp_scale.unwrap() as f64) / 1_000_000_000_f64; Ok(()) } diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs index 1dfbacd..3ce6b78 100644 --- a/remuxer/src/lib.rs +++ b/remuxer/src/lib.rs @@ -21,6 +21,7 @@ use std::{collections::VecDeque, fs::File, io::Write, path::PathBuf}; pub struct RemuxerContext {} impl RemuxerContext { + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self {} } @@ -63,7 +64,7 @@ impl RemuxerContext { info!("\t {}", info); let file = File::open(&source_path).context("opening source file")?; let mut index = - File::open(source_path.with_extension(&format!("si.{}", info.track_number))) + File::open(source_path.with_extension(format!("si.{}", info.track_number))) .context("opening seek index file")?; let index = bincode::decode_from_std_read::<SeekIndex, _, _>( &mut index, @@ -79,7 +80,6 @@ impl RemuxerContext { temp_index: 0, }) }) - .into_iter() .collect::<anyhow::Result<Vec<_>>>()?; output.write_tag(&MatroskaTag::Ebml(Master::Collected(vec![ @@ -101,7 +101,7 @@ impl RemuxerContext { output.write_tag(&MatroskaTag::Info(Master::Collected(vec![ MatroskaTag::TimestampScale(1_000_000), MatroskaTag::Duration(iteminfo.duration * 1000.0), - MatroskaTag::Title(iteminfo.title.clone()), + MatroskaTag::Title(iteminfo.title), MatroskaTag::MuxingApp("jellyremux".to_string()), MatroskaTag::WritingApp("jellything".to_string()), ])))?; @@ -145,7 +145,7 @@ impl RemuxerContext { if best_block.pts > cluster_pts + 2_000 { let cluster_content_size = 1 // timestamp tag + 1 // timestamp tag size - + EbmlWriter::vint_length(cluster_pts as u64) // timestamp tag value + + EbmlWriter::vint_length(cluster_pts) // timestamp tag value + p; let cluster_header_size = 4 // tag length + EbmlWriter::vint_length(cluster_content_size as u64)// size varint @@ -153,7 +153,7 @@ impl RemuxerContext { clusters.push(ClusterLayout { position: gp, timestamp: cluster_pts, - blocks: std::mem::replace(&mut cluster, vec![]), + blocks: std::mem::take(&mut cluster), }); cluster_pts = best_block.pts; @@ -174,6 +174,34 @@ impl RemuxerContext { clusters }; + output.write_tag(&MatroskaTag::Cues(Master::Collected( + segment_layout + .iter() + .map(|cluster| { + MatroskaTag::CuePoint(Master::Collected( + [ + MatroskaTag::CueTime(cluster.timestamp), + MatroskaTag::CueTrackPositions(Master::Collected( + [ + MatroskaTag::CueTrack(0), + MatroskaTag::CueClusterPosition(cluster.position as u64), + ] + .to_vec(), + )), + MatroskaTag::CueTrackPositions(Master::Collected( + [ + MatroskaTag::CueTrack(1), + MatroskaTag::CueClusterPosition(cluster.position as u64), + ] + .to_vec(), + )), + ] + .to_vec(), + )) + }) + .collect(), + )))?; + struct ReaderD<'a> { _info: SourceTrack, peek: Option<AbsoluteBlock>, @@ -206,6 +234,7 @@ impl RemuxerContext { }); } + let segment_start_position = output.position(); for (cluster_index, cluster) in segment_layout.into_iter().enumerate() { info!( "writing cluster {cluster_index} (pts_base={}) with {} blocks", @@ -214,9 +243,9 @@ impl RemuxerContext { ); debug!( "calculation was {} bytes off", - cluster.position as i64 - output.position() as i64 + cluster.position as i64 - (output.position() - segment_start_position) as i64 ); - let mut cluster_blocks = vec![MatroskaTag::Timestamp(cluster.timestamp as u64)]; + let mut cluster_blocks = vec![MatroskaTag::Timestamp(cluster.timestamp)]; for (block_index, iblock) in cluster.blocks { let kn = &mut ks[block_index]; let mut block = kn @@ -268,14 +297,14 @@ impl SegmentExtractIter<'_> { } pub fn read(&mut self) -> Result<()> { - let Unflat { children, item } = self.segment.next().ok_or(anyhow!("eof"))??; + let Unflat { children, item } = self.segment.n().ok_or(anyhow!("eof"))??; let mut pts_base = 0; match item { MatroskaTag::SeekHead(_) => {} MatroskaTag::Info(_) => {} MatroskaTag::Cluster(_) => { let mut children = children.unwrap(); - while let Some(Ok(Unflat { children, item })) = children.next() { + while let Some(Ok(Unflat { children, item })) = children.n() { match item { MatroskaTag::Crc32(_) => (), MatroskaTag::Timestamp(ts) => { @@ -286,18 +315,17 @@ impl SegmentExtractIter<'_> { trace!("group"); let mut children = children.unwrap(); - let mut duration = None; + // let mut duration = None; let mut block = None; - while let Some(Ok(Unflat { children: _, item })) = children.next() { + while let Some(Ok(Unflat { children: _, item })) = children.n() { match item { MatroskaTag::Block(buf) => block = Some(buf), - MatroskaTag::BlockDuration(v) => duration = Some(v), + // MatroskaTag::BlockDuration(v) => duration = Some(v), _ => debug!("ignored {item:?}"), } } // TODO duration - drop(duration); let block = Block::parse(&block.unwrap())?; if block.track == self.extract { trace!("block: track={} tso={}", block.track, block.timestamp_off); @@ -333,12 +361,13 @@ impl SegmentExtractIter<'_> { } pub fn track_to_ebml(number: u64, track: &SourceTrack) -> MatroskaTag { - let mut els = Vec::new(); - els.push(MatroskaTag::TrackNumber(number)); - els.push(MatroskaTag::TrackUID(number)); - els.push(MatroskaTag::FlagLacing(0)); - els.push(MatroskaTag::Language(track.language.clone())); - els.push(MatroskaTag::CodecID(track.codec.clone())); + let mut els = vec![ + MatroskaTag::TrackNumber(number), + MatroskaTag::TrackUID(number), + MatroskaTag::FlagLacing(0), + MatroskaTag::Language(track.language.clone()), + MatroskaTag::CodecID(track.codec.clone()), + ]; if let Some(d) = &track.default_duration { els.push(MatroskaTag::DefaultDuration(*d)); } diff --git a/server/src/library.rs b/server/src/library.rs index 6cb6c3a..258569e 100644 --- a/server/src/library.rs +++ b/server/src/library.rs @@ -39,9 +39,9 @@ pub struct Item { } impl Library { - pub fn open(path: &PathBuf) -> anyhow::Result<Self> { + pub fn open(path: &Path) -> anyhow::Result<Self> { Ok(Self { - root: Node::from_path(path.clone(), PathBuf::new(), true) + root: Node::from_path(path.to_path_buf(), PathBuf::new(), true) .context("indexing root")? .ok_or(anyhow!("root need directory.json"))?, }) @@ -51,10 +51,10 @@ impl Library { } pub fn nested(&self, path: &str) -> anyhow::Result<Arc<Node>> { let mut n = self.root.clone(); - if path == "" { + if path.is_empty() { return Ok(n); } - for seg in path.split("/") { + for seg in path.split('/') { n = n .get_directory()? .child_by_ident(seg) @@ -111,7 +111,7 @@ impl Node { .read_dir()? .filter_map(|e| { let e = e.unwrap(); - if (e.path().extension() == None || e.metadata().unwrap().is_dir()) + if (e.path().extension().is_none() || e.metadata().unwrap().is_dir()) && !e.path().ends_with("directory.json") { Some(e.path()) @@ -124,7 +124,6 @@ impl Node { .context(format!("loading {e:?}")) .transpose() }) - .into_iter() .collect::<anyhow::Result<Vec<_>>>()?; Ok(Some( @@ -149,7 +148,7 @@ impl Node { .to_string(); Ok(Some( Node::Item(Arc::new(Item { - fs_path: path.clone(), + fs_path: path, lib_path: lib_path.join(identifier.clone()), info: data, identifier, diff --git a/server/src/main.rs b/server/src/main.rs index 00543ce..250e29c 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -18,7 +18,7 @@ pub mod database; pub mod library; pub mod routes; -pub static CONF: Lazy<GlobalConfig> = Lazy::new(|| load_global_config()); +pub static CONF: Lazy<GlobalConfig> = Lazy::new(load_global_config); #[launch] fn rocket() -> _ { @@ -28,7 +28,7 @@ fn rocket() -> _ { .init(); #[cfg(feature = "bypass-auth")] - warn!("authentification bypass enabled"); + log::warn!("authentification bypass enabled"); let remuxer = RemuxerContext::new(); let library = Library::open(&CONF.library_path).unwrap(); diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs index 469ad07..e7547bd 100644 --- a/server/src/routes/stream.rs +++ b/server/src/routes/stream.rs @@ -17,15 +17,15 @@ use rocket::{ }; use std::{ ops::{Deref, Range}, - path::PathBuf, + path::{PathBuf, Path}, }; use tokio::io::{duplex, DuplexStream}; use tokio_util::io::SyncIoBridge; -pub fn stream_uri(path: &PathBuf, tracks: &Vec<u64>, webm: bool) -> String { +pub fn stream_uri(path: &Path, tracks: &[u64], webm: bool) -> String { format!( "/stream/{}?tracks={}&webm={}", - path.to_str().unwrap().to_string(), + path.to_str().unwrap(), tracks .iter() .map(|v| format!("{v}")) @@ -54,9 +54,8 @@ pub fn r_stream( .get_item()?; let remuxer = remuxer.deref().clone(); let tracks = tracks - .split(",") + .split(',') .map(|e| e.parse().map_err(|_| anyhow!("invalid number"))) - .into_iter() .collect::<Result<Vec<_>, _>>()?; let b = SyncIoBridge::new(b); @@ -119,10 +118,10 @@ impl RequestRange { Ok(Self( s.strip_prefix("bytes=") .ok_or(anyhow!("prefix expected"))? - .split(",") + .split(',') .map(|s| { let (l, r) = s - .split_once("-") + .split_once('-') .ok_or(anyhow!("range delimeter missing"))?; let km = |s: &str| { if s.is_empty() { @@ -133,7 +132,6 @@ impl RequestRange { }; Ok(km(l)?..km(r)?) }) - .into_iter() .collect::<Result<Vec<_>>>()?, )) } diff --git a/server/src/routes/ui/account/session.rs b/server/src/routes/ui/account/session.rs index 3457d41..6059311 100644 --- a/server/src/routes/ui/account/session.rs +++ b/server/src/routes/ui/account/session.rs @@ -6,7 +6,6 @@ use crate::{ database::{Database, User}, routes::ui::error::MyError, - CONF, }; use anyhow::anyhow; use rocket::{ @@ -29,7 +28,7 @@ impl Session { #[cfg(not(feature = "bypass-auth"))] let username = cookie.value(); #[cfg(feature = "bypass-auth")] - let username = CONF.admin_username.to_string(); + let username = crate::CONF.admin_username.to_string(); let db = req.guard::<&State<Database>>().await.unwrap(); let user = db diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index f216df2..dd98a61 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -26,10 +26,9 @@ pub async fn r_library_node( ) -> Result<DynLayoutPage<'_>, MyError> { let node = library .nested_path(&path) - .context("retrieving library node")? - .clone(); + .context("retrieving library node")?; Ok(LayoutPage { - title: format!("{}", node.title()), + title: node.title().to_string(), content: markup::new! { @NodePage { node: node.clone() } }, diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs index 0fc0364..866787a 100644 --- a/server/src/routes/ui/player.rs +++ b/server/src/routes/ui/player.rs @@ -13,9 +13,9 @@ use crate::{ }; use jellycommon::SourceTrackKind; use rocket::{get, FromForm, State}; -use std::{path::PathBuf, sync::Arc}; +use std::{path::{PathBuf, Path}, sync::Arc}; -pub fn player_uri(path: &PathBuf) -> String { +pub fn player_uri(path: &Path) -> String { format!("/player/{}", path.to_str().unwrap()) } @@ -36,7 +36,7 @@ pub fn r_player( ) -> MyResult<DynLayoutPage<'_>> { let item = library.nested_path(&path)?.get_item()?; if conf.a.is_none() && conf.v.is_none() && conf.s.is_none() { - return player_conf(item.clone()); + return player_conf(item); } let tracks = [] |