fix: remove sqlx from API layer, read TTL from TranscodeManager, init local_files from DB on startup

This commit is contained in:
2026-03-16 04:08:52 +01:00
parent d88afbfe2e
commit 50df852416
3 changed files with 54 additions and 19 deletions

View File

@@ -168,15 +168,6 @@ async fn rebuild_registry(state: &AppState) -> DomainResult<()> {
Arc::new(infra::LocalFilesProvider::new(Arc::clone(&idx), lf_cfg, tm.clone())),
);
// Sync cleanup_ttl_hours to transcode_settings table so
// GET /files/transcode-settings returns the configured value.
let _ = sqlx::query(
"UPDATE transcode_settings SET cleanup_ttl_hours = ? WHERE id = 1",
)
.bind(cleanup_ttl_hours as i64)
.execute(&sqlite_pool)
.await;
*state.local_index.write().await = Some(idx);
*state.transcode_manager.write().await = tm;
*state.sqlite_pool.write().await = Some(sqlite_pool);

View File

@@ -256,17 +256,10 @@ async fn get_transcode_settings(
State(state): State<AppState>,
CurrentUser(_user): CurrentUser,
) -> Result<Json<TranscodeSettingsResponse>, ApiError> {
let pool = state.sqlite_pool.read().await.clone()
.ok_or_else(|| ApiError::not_implemented("sqlite not available"))?;
let (ttl,): (i64,) =
sqlx::query_as("SELECT cleanup_ttl_hours FROM transcode_settings WHERE id = 1")
.fetch_one(&pool)
.await
.map_err(|e| ApiError::internal(e.to_string()))?;
let tm = state.transcode_manager.read().await.clone()
.ok_or_else(|| ApiError::not_implemented("TRANSCODE_DIR not configured"))?;
Ok(Json(TranscodeSettingsResponse {
cleanup_ttl_hours: ttl as u32,
cleanup_ttl_hours: tm.get_cleanup_ttl(),
}))
}