ChatGPT Codex 5.5 xhigh refactored even more

This commit is contained in:
2026-05-02 15:31:37 +02:00
parent 86d0f93ede
commit b4585b663a
24 changed files with 2160 additions and 1972 deletions
@@ -0,0 +1,38 @@
//! Local game directory monitor.
use std::time::Duration;
use tokio::sync::mpsc::UnboundedSender;
use crate::{
PeerEvent,
config::LOCAL_GAME_MONITOR_INTERVAL_SECS,
context::Ctx,
handlers::update_and_announce_games,
local_games::scan_local_library,
};
/// Monitors the local game directory for changes.
pub async fn run_local_game_monitor(tx_notify_ui: UnboundedSender<PeerEvent>, ctx: Ctx) {
log::info!(
"Starting local game directory monitor ({LOCAL_GAME_MONITOR_INTERVAL_SECS}s interval)"
);
let mut interval = tokio::time::interval(Duration::from_secs(LOCAL_GAME_MONITOR_INTERVAL_SECS));
loop {
interval.tick().await;
let game_dir = { ctx.game_dir.read().await.clone() };
if let Some(game_dir) = game_dir {
match scan_local_library(&game_dir).await {
Ok(scan) => {
update_and_announce_games(&ctx, &tx_notify_ui, scan).await;
}
Err(err) => {
log::error!("Failed to scan local games directory: {err}");
}
}
}
}
}