From fdd6e10e3a19b7bc51bba53e04ab9e719b7bdd1c Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 8 Sep 2025 18:06:09 +0300 Subject: [PATCH] use long var name --- src/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9cbdf00..8ba1658 100644 --- a/src/main.rs +++ b/src/main.rs @@ -156,13 +156,14 @@ fn response( stream: &mut TlsStream, ) { debug!("Incoming request from `{peer}` to `{}`", request.url.path()); - let p = request.url.path().trim_matches('/'); + let path = request.url.path().trim_matches('/'); // try index page - if p.is_empty() { + if path.is_empty() { send( &match index( config, public, + request.url.query(), request.url.query_pairs().find_map(|a| { if a.0 == "page" { a.1.parse::().ok() @@ -195,7 +196,7 @@ fn response( ) } // try search - else if p == "search" { + else if path == "search" { send( &response::Input::Default(response::input::Default { message: Some("Keyword, file, hash...".into()), @@ -213,7 +214,7 @@ fn response( ) } // try info page - else if let Ok(id) = Id20::from_str(p) + else if let Ok(id) = Id20::from_str(path) && let Some(torrent) = public.torrent(id) { send( @@ -282,11 +283,16 @@ fn send(data: &[u8], stream: &mut TlsStream, callback: impl FnOnce(Re // rotes -fn index(config: &Config, public: &Public, page: Option) -> Result { +fn index( + config: &Config, + public: &Public, + keyword: Option<&str>, + page: Option, +) -> Result { use plurify::Plurify; let (total, torrents) = public.torrents( - None, // @TODO + keyword, Some((Sort::Modified, Order::Desc)), page.map(|p| if p > 0 { p - 1 } else { p } * public.default_limit), Some(public.default_limit),