This commit is contained in:
2025-11-14 11:28:55 +01:00
parent f88fa5794c
commit 293ede96ed
2 changed files with 7 additions and 0 deletions
+4
View File
@@ -1854,6 +1854,10 @@ async fn handle_peer_stream(
if let Some(ref db) = *db_guard { if let Some(ref db) = *db_guard {
db.all_games().into_iter().cloned().collect::<Vec<Game>>() db.all_games().into_iter().cloned().collect::<Vec<Game>>()
} else { } else {
// Local database not loaded yet, return empty result
log::info!(
"Local game database not yet loaded, responding with empty game list"
);
Vec::new() Vec::new()
} }
}; };
@@ -892,6 +892,9 @@ pub fn run() {
*state.peer_ctrl.write().await = Some(peer_ctrl); *state.peer_ctrl.write().await = Some(peer_ctrl);
log::info!("Peer system initialized successfully with games directory"); log::info!("Peer system initialized successfully with games directory");
// Wait a moment for local game database to be loaded before starting discovery
tokio::time::sleep(tokio::time::Duration::from_millis(2000)).await;
// Start peer discovery and request games from other peers // Start peer discovery and request games from other peers
if let Err(e) = request_games(state).await { if let Err(e) = request_games(state).await {
log::error!("Failed to request games after peer init: {e}"); log::error!("Failed to request games after peer init: {e}");