Skip to content

Commit

Permalink
Route fixes caught in more thorough testing
Browse files Browse the repository at this point in the history
  • Loading branch information
niamu committed Nov 27, 2023
1 parent b13b745 commit 84c8913
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 8 additions & 2 deletions dim-web/src/routes/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use fuzzy_matcher::skim::SkimMatcherV2;
use fuzzy_matcher::FuzzyMatcher;
use http::StatusCode;
use serde::Serialize;
use serde::Deserialize;

use crate::error::DimErrorWrapper;
use crate::AppState;
Expand Down Expand Up @@ -233,13 +234,18 @@ pub async fn library_get_media(State(AppState { conn, .. }): State<AppState>, Pa
Json(result).into_response()
}

#[derive(Deserialize)]
pub struct UnmatchedArgs {
search: Option<String>,
}

/// Method mapped to `GET` /api/v1/library/<id>/unmatched` returns a list of all unmatched medias
/// to be displayed in the library pages.
///
pub async fn library_get_unmatched(
State(AppState { conn, .. }): State<AppState>,
Path(id): Path<i64>,
Query(search): Query<Option<String>>,
Query(params): Query<UnmatchedArgs>,
) -> Response {
let mut tx = match conn.read().begin().await {
Ok(tx) => tx,
Expand All @@ -264,7 +270,7 @@ pub async fn library_get_unmatched(
// we want to pre-sort to ensure our tree is somewhat ordered.
files.sort_by(|a, b| a.target_file.cmp(&b.target_file));

if let Some(search) = search {
if let Some(search) = params.search {
let matcher = SkimMatcherV2::default();

let mut matched_files = files
Expand Down
6 changes: 2 additions & 4 deletions dim-web/src/routes/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,7 @@ pub async fn get_init(
/// Method mapped to `/api/v1/stream/<id>/data/<chunk..>` returns a chunk for stream `id`.
pub async fn get_chunk(
State(AppState { state, .. }): State<AppState>,
Path(id): Path<String>,
Path(chunk): Path<PathBuf>,
Path((id, chunk)): Path<(String, PathBuf)>,
) -> Result<impl IntoResponse, errors::StreamingErrors> {
let extension = chunk
.extension()
Expand Down Expand Up @@ -643,8 +642,7 @@ pub async fn get_subtitle_ass(
/// on web platforms.
pub async fn should_client_hard_seek(
State(AppState { state, stream_tracking, .. }): State<AppState>,
Path(gid): Path<String>,
Path(chunk_num): Path<u32>,
Path((gid, chunk_num)): Path<(String, u32)>,
) -> Result<impl IntoResponse, errors::StreamingErrors> {
let gid = match Uuid::parse_str(gid.as_str()) {
Ok(x) => x,
Expand Down

0 comments on commit 84c8913

Please sign in to comment.