diff options
-rw-r--r-- | base/src/cache.rs | 4 | ||||
-rw-r--r-- | base/src/database.rs | 2 | ||||
-rw-r--r-- | common/src/impl.rs | 2 | ||||
-rw-r--r-- | import/src/lib.rs | 12 | ||||
-rw-r--r-- | import/src/tmdb.rs | 10 | ||||
-rw-r--r-- | matroska/src/write.rs | 2 | ||||
-rw-r--r-- | remuxer/src/lib.rs | 4 | ||||
-rw-r--r-- | server/src/routes/api.rs | 5 | ||||
-rw-r--r-- | server/src/routes/compat/jellyfin/mod.rs | 32 | ||||
-rw-r--r-- | server/src/routes/ui/admin/mod.rs | 4 | ||||
-rw-r--r-- | server/src/routes/ui/mod.rs | 2 | ||||
-rw-r--r-- | server/src/routes/ui/player.rs | 6 |
12 files changed, 40 insertions, 45 deletions
diff --git a/base/src/cache.rs b/base/src/cache.rs index e2b540b..d6aa15f 100644 --- a/base/src/cache.rs +++ b/base/src/cache.rs @@ -44,7 +44,7 @@ pub fn cache_location(seed: &[&str]) -> (usize, CachePath) { d.update(b"\0"); } let d = d.finalize(); - let n = d[0] as usize | (d[1] as usize) << 8 | (d[2] as usize) << 16 | (d[3] as usize) << 24; + let n = d[0] as usize | ((d[1] as usize) << 8) | ((d[2] as usize) << 16) | ((d[3] as usize) << 24); let fname = base64::engine::general_purpose::URL_SAFE.encode(d); let fname = &fname[..22]; let fname = format!("{}-{}", seed[0], fname); // about 128 bits @@ -92,7 +92,7 @@ where Ok(location) } -thread_local! { pub static WITHIN_CACHE_FILE: AtomicBool = AtomicBool::new(false); } +thread_local! { pub static WITHIN_CACHE_FILE: AtomicBool = const { AtomicBool::new(false) }; } pub fn cache_file<Fun>(seed: &[&str], mut generate: Fun) -> Result<CachePath, anyhow::Error> where diff --git a/base/src/database.rs b/base/src/database.rs index 54ead92..407db29 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -144,7 +144,7 @@ impl Database { let txn = self.inner.begin_read()?; let t_node = txn.open_table(T_USER_NODE)?; if let Some(node) = t_node.get((username, id.0))? { - Ok(Some(node.value().0.into())) + Ok(Some(node.value().0)) } else { Ok(None) } diff --git a/common/src/impl.rs b/common/src/impl.rs index 1aeac22..6415d53 100644 --- a/common/src/impl.rs +++ b/common/src/impl.rs @@ -183,7 +183,7 @@ impl<'a> rocket::request::FromParam<'a> for NodeID { hex::decode_to_slice(id, &mut k)?; Ok(NodeID(k)) } else { - Ok(NodeID::from_slug(¶m)) + Ok(NodeID::from_slug(param)) } } } diff --git a/import/src/lib.rs b/import/src/lib.rs index 7b19a61..8cc9ddd 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -156,17 +156,17 @@ fn import_traverse( let mtime = meta.modified()?.duration_since(UNIX_EPOCH)?.as_secs(); if incremental { - if let Some(last_mtime) = db.get_import_file_mtime(&path)? { + if let Some(last_mtime) = db.get_import_file_mtime(path)? { if last_mtime >= mtime { return Ok(()); } } } - import_file(&db, apis, rthandle, &path, parent, visibility).context(anyhow!("{path:?}"))?; - db.set_import_file_mtime(&path, mtime)?; + import_file(db, apis, rthandle, path, parent, visibility).context(anyhow!("{path:?}"))?; + db.set_import_file_mtime(path, mtime)?; } - return Ok(()); + Ok(()) } fn import_file( @@ -333,7 +333,7 @@ fn import_media_file( ) ) } else { - make_kebab(&filepath_stem) + make_kebab(filepath_stem) } }); @@ -497,7 +497,7 @@ fn import_media_file( rthandle.block_on(tmdb.episode_details(tmdb_id, season, episode))?; if let Some(still) = &tmdb_details.still_path { poster = Some( - AssetInner::Cache(rthandle.block_on(tmdb.image(&still))?).ser(), + AssetInner::Cache(rthandle.block_on(tmdb.image(still))?).ser(), ) } } diff --git a/import/src/tmdb.rs b/import/src/tmdb.rs index 70e95ce..1e7849f 100644 --- a/import/src/tmdb.rs +++ b/import/src/tmdb.rs @@ -50,7 +50,7 @@ impl Tmdb { info!("searching tmdb: {query:?}"); Ok(self .client - .get(&format!( + .get(format!( "https://api.themoviedb.org/3/search/{kind}?query={}?api_key={}", query.replace(" ", "+"), self.key @@ -71,7 +71,7 @@ impl Tmdb { info!("fetching details: {id:?}"); Ok(self .client - .get(&format!( + .get(format!( "https://api.themoviedb.org/3/{kind}/{id}?api_key={}", self.key, )) @@ -88,7 +88,7 @@ impl Tmdb { async_cache_memory(&["api-tmdb-search", &format!("{id}")], || async move { Ok(self .client - .get(&format!( + .get(format!( "https://api.themoviedb.org/3/person/{id}/images?api_key={}", self.key, )) @@ -105,7 +105,7 @@ impl Tmdb { info!("downloading image {path:?}"); let mut res = self .image_client - .get(&format!("https://image.tmdb.org/t/p/original{path}")) + .get(format!("https://image.tmdb.org/t/p/original{path}")) .send() .await? .error_for_status()?; @@ -127,7 +127,7 @@ impl Tmdb { info!("tmdb episode details {series_id} S={season} E={episode}"); Ok(self .image_client - .get(&format!("https://api.themoviedb.org/3/tv/{series_id}/season/{season}/episode/{episode}?api_key={}", self.key)) + .get(format!("https://api.themoviedb.org/3/tv/{series_id}/season/{season}/episode/{episode}?api_key={}", self.key)) .send() .await? .error_for_status()? diff --git a/matroska/src/write.rs b/matroska/src/write.rs index 5d2f9fb..58923c6 100644 --- a/matroska/src/write.rs +++ b/matroska/src/write.rs @@ -231,7 +231,7 @@ impl WriteValue for String { } fn size(&self) -> usize { - vint_length(self.as_bytes().len() as u64) + self.as_bytes().len() + vint_length(self.len() as u64) + self.len() } } impl WriteValue for EbmlSize { diff --git a/remuxer/src/lib.rs b/remuxer/src/lib.rs index b46369e..dc713dc 100644 --- a/remuxer/src/lib.rs +++ b/remuxer/src/lib.rs @@ -53,8 +53,8 @@ pub fn ebml_track_entry( MatroskaTag::FlagLacing(0), MatroskaTag::Language(track.language.clone()), MatroskaTag::CodecID(track.codec.clone()), - MatroskaTag::CodecDelay(track.codec_delay.clone()), - MatroskaTag::SeekPreRoll(track.seek_pre_roll.clone()), + MatroskaTag::CodecDelay(track.codec_delay), + MatroskaTag::SeekPreRoll(track.seek_pre_roll), ]; if let Some(d) = &track.default_duration { els.push(MatroskaTag::DefaultDuration(*d)); diff --git a/server/src/routes/api.rs b/server/src/routes/api.rs index 4e2211f..83569e0 100644 --- a/server/src/routes/api.rs +++ b/server/src/routes/api.rs @@ -64,9 +64,8 @@ pub fn r_api_nodes_modified_since( ) -> MyResult<Json<Vec<NodeID>>> { let mut nodes = database.get_nodes_modified_since(since)?; nodes.retain(|id| { - database.get_node(*id).map_or(false, |n| { - n.as_ref() - .map_or(false, |n| n.visibility >= Visibility::Reduced) + database.get_node(*id).is_ok_and(|n| { + n.as_ref().is_some_and(|n| n.visibility >= Visibility::Reduced) }) }); Ok(Json(nodes)) diff --git a/server/src/routes/compat/jellyfin/mod.rs b/server/src/routes/compat/jellyfin/mod.rs index eac2f55..ab36a8c 100644 --- a/server/src/routes/compat/jellyfin/mod.rs +++ b/server/src/routes/compat/jellyfin/mod.rs @@ -38,10 +38,10 @@ use serde::Deserialize; use serde_json::{json, Value}; use std::{collections::BTreeMap, net::IpAddr}; -const SERVER_ID: &'static str = "1694a95daf70708147f16103ce7b7566"; -const USER_ID: &'static str = "33f772aae6c2495ca89fe00340dbd17c"; -const VERSION: &'static str = "10.10.0"; -const LOCAL_ADDRESS: &'static str = "http://127.0.0.1:8000"; +const SERVER_ID: &str = "1694a95daf70708147f16103ce7b7566"; +const USER_ID: &str = "33f772aae6c2495ca89fe00340dbd17c"; +const VERSION: &str = "10.10.0"; +const LOCAL_ADDRESS: &str = "http://127.0.0.1:8000"; #[get("/System/Info/Public")] pub fn r_jellyfin_system_info_public_case() -> Json<Value> { @@ -300,12 +300,12 @@ pub fn r_jellyfin_items( let filter_kind = query .include_item_types - .and_then(|n| match n.as_str() { - "Movie" => Some(vec![FilterProperty::KindMovie]), - "Audio" => Some(vec![FilterProperty::KindMusic]), - "Video" => Some(vec![FilterProperty::KindVideo]), - "TvChannel" => Some(vec![FilterProperty::KindChannel]), - _ => Some(vec![]), + .map(|n| match n.as_str() { + "Movie" => vec![FilterProperty::KindMovie], + "Audio" => vec![FilterProperty::KindMusic], + "Video" => vec![FilterProperty::KindVideo], + "TvChannel" => vec![FilterProperty::KindChannel], + _ => vec![], }) .or(if query.internal_artists { Some(vec![]) @@ -498,8 +498,8 @@ pub fn r_jellyfin_playback_bitratetest(_session: Session, Size: usize) -> Vec<u8 } #[post("/Sessions/Capabilities/Full")] -pub fn r_jellyfin_sessions_capabilities_full(_session: Session) -> () { - () +pub fn r_jellyfin_sessions_capabilities_full(_session: Session) { + } #[derive(Deserialize)] @@ -742,7 +742,7 @@ fn item_object(node: &Node, userdata: &NodeUserData) -> JellyfinItem { genres: vec![], remote_trailers: vec![], provider_ids: BTreeMap::new(), - is_folder: !node.media.is_some(), + is_folder: node.media.is_none(), parent_id: "todo-parent".to_owned(), // TODO r#type: match node.kind { NodeKind::Movie | NodeKind::Video | NodeKind::ShortFormVideo => JellyfinItemType::Movie, @@ -796,11 +796,7 @@ fn item_object(node: &Node, userdata: &NodeUserData) -> JellyfinItem { location_type: node.media.as_ref().map(|_| "FileSystem".to_owned()), play_access: node.media.as_ref().map(|_| "Full".to_owned()), container: node.media.as_ref().map(|_| "webm".to_owned()), - run_time_ticks: if let Some(m) = &node.media { - Some((m.duration * 10_000_000.) as i64) - } else { - None - }, + run_time_ticks: node.media.as_ref().map(|m| (m.duration * 10_000_000.) as i64), media_sources: media_source.as_ref().map(|s| vec![s.clone()]), media_streams: media_source.as_ref().map(|s| s.media_streams.clone()), path: node diff --git a/server/src/routes/ui/admin/mod.rs b/server/src/routes/ui/admin/mod.rs index 10c7365..15cc5c0 100644 --- a/server/src/routes/ui/admin/mod.rs +++ b/server/src/routes/ui/admin/mod.rs @@ -171,10 +171,10 @@ pub async fn r_admin_update_search( .await .unwrap(); admin_dashboard( - &database, + database, Some( r.map_err(|e| e.into()) - .map(|_| format!("Search index updated")), + .map(|_| "Search index updated".to_string()), ), ) .await diff --git a/server/src/routes/ui/mod.rs b/server/src/routes/ui/mod.rs index bffdfdd..9a3e61b 100644 --- a/server/src/routes/ui/mod.rs +++ b/server/src/routes/ui/mod.rs @@ -68,7 +68,7 @@ impl<'r> Responder<'r, 'static> for HtmlTemplate<'_> { self.0.render(&mut out).unwrap(); Response::build() .header(ContentType::HTML) - .sized_body(out.as_bytes().len(), Cursor::new(out)) + .sized_body(out.len(), Cursor::new(out)) .ok() } } diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs index f680a45..2f28f74 100644 --- a/server/src/routes/ui/player.rs +++ b/server/src/routes/ui/player.rs @@ -58,12 +58,12 @@ fn jellynative_url(action: &str, seek: f64, secret: &str, node: &str, session: & } #[get("/n/<id>/player?<conf..>", rank = 4)] -pub fn r_player<'a>( +pub fn r_player( sess: Session, - db: &'a State<Database>, + db: &State<Database>, id: NodeID, conf: PlayerConfig, -) -> MyResult<Either<DynLayoutPage<'a>, Redirect>> { +) -> MyResult<Either<DynLayoutPage<'_>, Redirect>> { let node = db.get_node(id)?.ok_or(anyhow!("node does not exist"))?; let native_session = |action: &str| { |