From 1dd25f682bfb6e4038b57f686612d8652be81f25 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Fri, 15 Nov 2024 12:15:50 +0100 Subject: [PATCH] [server] only provide games that exist in games folder --- crates/lanspread-server/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/lanspread-server/src/main.rs b/crates/lanspread-server/src/main.rs index 93036ae..8dab420 100644 --- a/crates/lanspread-server/src/main.rs +++ b/crates/lanspread-server/src/main.rs @@ -319,6 +319,17 @@ async fn main() -> eyre::Result<()> { let eti_games = eti::get_games(&cli.db).await?; let mut games: Vec = eti_games.into_iter().map(eti_game_to_game).collect(); + + // Filter games based on existing folders + games.retain(|game| { + let game_folder = cli.folder.join(&game.id); + let exists = game_folder.exists() && game_folder.is_dir(); + if !exists { + tracing::debug!("Skipping game {}: folder not found", game.id); + } + exists + }); + let thumbnails = Thumbnails::new(cli.thumbnails); // add thumbnails to games