diff --git a/src/linux/launchers/bottles.rs b/src/linux/launchers/bottles.rs index 0e9284b..3eef1dd 100644 --- a/src/linux/launchers/bottles.rs +++ b/src/linux/launchers/bottles.rs @@ -222,13 +222,9 @@ impl Bottles { let mut parsed_games_data: Vec = Vec::new(); let mut file_content_str: &str = &file_content; - loop { - let Ok((new_file_content, parsed_data)) = parse_game_from_bottle_yml(file_content_str) - else { - break; - }; + while let Ok((new_file_content, parsed_data)) = parse_game_from_bottle_yml(file_content_str) + { file_content_str = new_file_content; - parsed_games_data.push(parsed_data) } @@ -263,13 +259,9 @@ impl Bottles { let mut parsed_data: Vec = Vec::new(); let mut library_file_content_str: &str = &library_file_content; - loop { - let Ok((new_library_file_content, parsed_library_data)) = - parse_game_from_library(library_file_content_str) - else { - break; - }; - + while let Ok((new_library_file_content, parsed_library_data)) = + parse_game_from_library(library_file_content_str) + { library_file_content_str = new_library_file_content; parsed_data.push(parsed_library_data); } diff --git a/src/linux/launchers/lutris.rs b/src/linux/launchers/lutris.rs index 8a93114..864fd08 100644 --- a/src/linux/launchers/lutris.rs +++ b/src/linux/launchers/lutris.rs @@ -19,17 +19,21 @@ use crate::{ }; // DB DATA -------------------------------------------------------------------------------- -const PGA_DB_QUERY: &str = - "SELECT id, name, slug, installer_slug, parent_slug, directory, playtime FROM games;"; +const PGA_DB_QUERY: &str = "\ + SELECT id, name, slug, installer_slug, parent_slug, directory, playtime, installed, runner \ + FROM games;\ +"; /// Data returned directly by the query to the pga.db #[derive(Debug, Clone)] struct DbRow { run_id: String, + runner: Option, title: String, slug: String, installer_slug: Option, game_dir: Option, + installed: bool, _parent_slug: Option, _playtime: Option, } @@ -40,12 +44,14 @@ impl<'stmt> TryFrom<&rusqlite::Row<'stmt>> for DbRow { fn try_from(row: &rusqlite::Row) -> std::result::Result { Ok(Self { run_id: row.get::<&str, i32>("id")?.to_string(), + runner: row.get("runner")?, title: row.get("name")?, slug: row.get("slug")?, installer_slug: row.get("installer_slug")?, _parent_slug: row.get("parent_slug")?, game_dir: row.get("directory")?, _playtime: row.get("playtime")?, + installed: row.get("installed")?, }) } } @@ -125,6 +131,13 @@ impl Lutris { stmt.query(params![]) .inspect_err(|e| error!("{LAUNCHER} - failed to execute DB query: {e}"))? .map(|r| DbRow::try_from(r)) + .filter(|r| Ok(r.installed)) + // WARN: Ignore Steam entries entirely. + // This is more of an opinion, as these lead to duplicate entries, + // and do not inherently belong to Lutris anyway (will still just + // launch through Steam). Feel free to start a discussion if you disagree. + // See: https://github.com/Rolv-Apneseth/lib_game_detector/issues/53 + .filter(|r| Ok(r.runner.as_ref().is_none_or(|s| s != "steam"))) .collect::>() .inspect(|rows| { if rows.is_empty() { diff --git a/tests/file_system_mocks/linux/.local/share/lutris/pga.db b/tests/file_system_mocks/linux/.local/share/lutris/pga.db index be6bb42..f23f858 100644 Binary files a/tests/file_system_mocks/linux/.local/share/lutris/pga.db and b/tests/file_system_mocks/linux/.local/share/lutris/pga.db differ