feat: implement transcode settings repository and integrate with local-files provider

This commit is contained in:
2026-03-16 04:24:39 +01:00
parent 50df852416
commit 9d792249c9
12 changed files with 269 additions and 177 deletions

View File

@@ -16,6 +16,9 @@ use crate::config::Config;
use crate::events::EventBus;
use crate::log_layer::LogLine;
use domain::{ActivityLogRepository, ChannelService, ProviderConfigRepository, ScheduleEngineService, UserService};
#[cfg(feature = "local-files")]
use domain::TranscodeSettingsRepository;
use k_core::db::DatabasePool;
#[derive(Clone)]
pub struct AppState {
@@ -43,12 +46,11 @@ pub struct AppState {
/// TranscodeManager for FFmpeg HLS transcoding (requires TRANSCODE_DIR).
#[cfg(feature = "local-files")]
pub transcode_manager: Arc<tokio::sync::RwLock<Option<Arc<infra::TranscodeManager>>>>,
/// SQLite pool for transcode settings CRUD.
/// Repository for transcode settings persistence.
#[cfg(feature = "local-files")]
pub sqlite_pool: Arc<tokio::sync::RwLock<Option<sqlx::SqlitePool>>>,
/// Raw sqlite pool — always present when running SQLite, used for local-files hot-reload.
#[cfg(feature = "local-files")]
pub raw_sqlite_pool: Option<sqlx::SqlitePool>,
pub transcode_settings_repo: Option<Arc<dyn TranscodeSettingsRepository>>,
/// Database pool — used by infra factory functions for hot-reload.
pub db_pool: Arc<DatabasePool>,
}
impl AppState {
@@ -63,6 +65,9 @@ impl AppState {
log_tx: broadcast::Sender<LogLine>,
log_history: Arc<Mutex<VecDeque<LogLine>>>,
activity_log_repo: Arc<dyn ActivityLogRepository>,
db_pool: Arc<DatabasePool>,
#[cfg(feature = "local-files")]
transcode_settings_repo: Option<Arc<dyn TranscodeSettingsRepository>>,
) -> anyhow::Result<Self> {
let cookie_key = Key::derive_from(config.cookie_secret.as_bytes());
@@ -144,9 +149,8 @@ impl AppState {
#[cfg(feature = "local-files")]
transcode_manager: Arc::new(tokio::sync::RwLock::new(None)),
#[cfg(feature = "local-files")]
sqlite_pool: Arc::new(tokio::sync::RwLock::new(None)),
#[cfg(feature = "local-files")]
raw_sqlite_pool: None,
transcode_settings_repo,
db_pool,
})
}
}