pinakes-core: fix minor clippy warnings; add toggle for Swagger UI generation

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ie33a5d17b774289023e3855789d3adc86a6a6964
This commit is contained in:
raf 2026-03-21 02:15:31 +03:00
commit aa68d742c9
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 12 additions and 6 deletions

View file

@ -49,6 +49,9 @@ pinakes-plugin-api.workspace = true
wasmtime.workspace = true wasmtime.workspace = true
ed25519-dalek.workspace = true ed25519-dalek.workspace = true
[features]
ffmpeg-tests = []
[lints] [lints]
workspace = true workspace = true

View file

@ -1126,6 +1126,10 @@ pub struct ServerConfig {
/// TLS/HTTPS configuration /// TLS/HTTPS configuration
#[serde(default)] #[serde(default)]
pub tls: TlsConfig, 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 /// TLS/HTTPS configuration for secure connections
@ -1470,6 +1474,7 @@ impl Default for Config {
cors_enabled: false, cors_enabled: false,
cors_origins: vec![], cors_origins: vec![],
tls: TlsConfig::default(), tls: TlsConfig::default(),
swagger_ui: true,
}, },
ui: UiConfig::default(), ui: UiConfig::default(),
accounts: AccountsConfig::default(), accounts: AccountsConfig::default(),

View file

@ -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(|_| { let offset_ms = i32::try_from(subtitle.offset_ms).map_err(|_| {
PinakesError::InvalidOperation(format!( PinakesError::InvalidOperation(format!(
"subtitle offset_ms {} exceeds i32 range", "subtitle offset_ms {} exceeds i32 range",
@ -3791,7 +3791,7 @@ impl StorageBackend for PostgresBackend {
is_embedded: row.get("is_embedded"), is_embedded: row.get("is_embedded"),
track_index: row track_index: row
.get::<_, Option<i32>>("track_index") .get::<_, Option<i32>>("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")), offset_ms: i64::from(row.get::<_, i32>("offset_ms")),
created_at: row.get("created_at"), created_at: row.get("created_at"),
} }

View file

@ -4297,9 +4297,7 @@ impl StorageBackend for SqliteBackend {
.as_ref() .as_ref()
.map(|p| p.to_string_lossy().to_string()); .map(|p| p.to_string_lossy().to_string());
let is_embedded = subtitle.is_embedded; let is_embedded = subtitle.is_embedded;
let track_index = subtitle let track_index = subtitle.track_index.map(i64::from);
.track_index
.map(|i| i64::try_from(i).unwrap_or(i64::MAX));
let offset_ms = subtitle.offset_ms; let offset_ms = subtitle.offset_ms;
let now = subtitle.created_at.to_rfc3339(); let now = subtitle.created_at.to_rfc3339();
let fut = tokio::task::spawn_blocking(move || { let fut = tokio::task::spawn_blocking(move || {
@ -4365,7 +4363,7 @@ impl StorageBackend for SqliteBackend {
is_embedded: row.get::<_, i32>(5)? != 0, is_embedded: row.get::<_, i32>(5)? != 0,
track_index: row track_index: row
.get::<_, Option<i64>>(6)? .get::<_, Option<i64>>(6)?
.map(|i| usize::try_from(i).unwrap_or(0)), .and_then(|i| u32::try_from(i).ok()),
offset_ms: row.get(7)?, offset_ms: row.get(7)?,
created_at: parse_datetime(&created_str), created_at: parse_datetime(&created_str),
}) })