From aa68d742c9bec6d648c82ea7f532801e6106b25c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 21 Mar 2026 02:15:31 +0300 Subject: [PATCH] pinakes-core: fix minor clippy warnings; add toggle for Swagger UI generation Signed-off-by: NotAShelf Change-Id: Ie33a5d17b774289023e3855789d3adc86a6a6964 --- crates/pinakes-core/Cargo.toml | 3 +++ crates/pinakes-core/src/config.rs | 5 +++++ crates/pinakes-core/src/storage/postgres.rs | 4 ++-- crates/pinakes-core/src/storage/sqlite.rs | 6 ++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/pinakes-core/Cargo.toml b/crates/pinakes-core/Cargo.toml index 4304012..c4ba043 100644 --- a/crates/pinakes-core/Cargo.toml +++ b/crates/pinakes-core/Cargo.toml @@ -49,6 +49,9 @@ pinakes-plugin-api.workspace = true wasmtime.workspace = true ed25519-dalek.workspace = true +[features] +ffmpeg-tests = [] + [lints] workspace = true diff --git a/crates/pinakes-core/src/config.rs b/crates/pinakes-core/src/config.rs index ecc8ae8..325ff30 100644 --- a/crates/pinakes-core/src/config.rs +++ b/crates/pinakes-core/src/config.rs @@ -1126,6 +1126,10 @@ pub struct ServerConfig { /// TLS/HTTPS configuration #[serde(default)] pub tls: TlsConfig, + /// Enable the Swagger UI at /api/docs. + /// Defaults to true. Set to false to disable in production if desired. + #[serde(default = "default_true")] + pub swagger_ui: bool, } /// TLS/HTTPS configuration for secure connections @@ -1470,6 +1474,7 @@ impl Default for Config { cors_enabled: false, cors_origins: vec![], tls: TlsConfig::default(), + swagger_ui: true, }, ui: UiConfig::default(), accounts: AccountsConfig::default(), diff --git a/crates/pinakes-core/src/storage/postgres.rs b/crates/pinakes-core/src/storage/postgres.rs index ea962aa..dbeb0e2 100644 --- a/crates/pinakes-core/src/storage/postgres.rs +++ b/crates/pinakes-core/src/storage/postgres.rs @@ -3729,7 +3729,7 @@ impl StorageBackend for PostgresBackend { )) }) }) - .transpose()?; + .transpose()?; // u32 fits in i32 for any valid track index, error is a safeguard let offset_ms = i32::try_from(subtitle.offset_ms).map_err(|_| { PinakesError::InvalidOperation(format!( "subtitle offset_ms {} exceeds i32 range", @@ -3791,7 +3791,7 @@ impl StorageBackend for PostgresBackend { is_embedded: row.get("is_embedded"), track_index: row .get::<_, Option>("track_index") - .map(|i| usize::try_from(i).unwrap_or(0)), + .map(|i| u32::try_from(i).unwrap_or(0)), offset_ms: i64::from(row.get::<_, i32>("offset_ms")), created_at: row.get("created_at"), } diff --git a/crates/pinakes-core/src/storage/sqlite.rs b/crates/pinakes-core/src/storage/sqlite.rs index 46ce813..ecc1b00 100644 --- a/crates/pinakes-core/src/storage/sqlite.rs +++ b/crates/pinakes-core/src/storage/sqlite.rs @@ -4297,9 +4297,7 @@ impl StorageBackend for SqliteBackend { .as_ref() .map(|p| p.to_string_lossy().to_string()); let is_embedded = subtitle.is_embedded; - let track_index = subtitle - .track_index - .map(|i| i64::try_from(i).unwrap_or(i64::MAX)); + let track_index = subtitle.track_index.map(i64::from); let offset_ms = subtitle.offset_ms; let now = subtitle.created_at.to_rfc3339(); let fut = tokio::task::spawn_blocking(move || { @@ -4365,7 +4363,7 @@ impl StorageBackend for SqliteBackend { is_embedded: row.get::<_, i32>(5)? != 0, track_index: row .get::<_, Option>(6)? - .map(|i| usize::try_from(i).unwrap_or(0)), + .and_then(|i| u32::try_from(i).ok()), offset_ms: row.get(7)?, created_at: parse_datetime(&created_str), })