fix: local_files hot-reload via RwLock state fields + rebuild_registry local_files case

This commit is contained in:
2026-03-16 03:58:36 +01:00
parent 89036ba62d
commit 712cf1deb9
4 changed files with 102 additions and 34 deletions

View File

@@ -80,6 +80,14 @@ async fn main() -> anyhow::Result<()> {
let db_pool = k_core::db::connect(&db_config).await?;
run_migrations(&db_pool).await?;
#[cfg(feature = "local-files")]
let raw_sqlite_pool: Option<sqlx::SqlitePool> = match &db_pool {
#[cfg(feature = "sqlite")]
k_core::db::DatabasePool::Sqlite(p) => Some(p.clone()),
#[allow(unreachable_patterns)]
_ => None,
};
let user_repo = build_user_repository(&db_pool).await?;
let channel_repo = build_channel_repository(&db_pool).await?;
let schedule_repo = build_schedule_repository(&db_pool).await?;
@@ -220,10 +228,19 @@ async fn main() -> anyhow::Result<()> {
.await?;
#[cfg(feature = "local-files")]
{
state.local_index = local_index;
state.transcode_manager = transcode_manager;
state.sqlite_pool = sqlite_pool_for_state;
{ state.raw_sqlite_pool = raw_sqlite_pool; }
#[cfg(feature = "local-files")]
if let Some(idx) = local_index {
*state.local_index.write().await = Some(idx);
}
#[cfg(feature = "local-files")]
if let Some(tm) = transcode_manager {
*state.transcode_manager.write().await = Some(tm);
}
#[cfg(feature = "local-files")]
if let Some(pool) = sqlite_pool_for_state {
*state.sqlite_pool.write().await = Some(pool);
}
let server_config = ServerConfig {