Compare commits
3 Commits
98126a72da
...
02d84c4d84
Author | SHA1 | Date | |
---|---|---|---|
02d84c4d84
|
|||
ca40a62ff8
|
|||
3dcc0271b8
|
@@ -150,18 +150,17 @@ fn run_game(id: String, state: tauri::State<LanSpreadState>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_game_install_state_from_path(game_db: &mut GameDB, path: &Path, installed: bool) {
|
fn set_game_install_state_from_path(game_db: &mut GameDB, path: &Path, installed: bool) {
|
||||||
if let Some(file_name) = path.file_name() {
|
if let Some(file_name) = path.file_name()
|
||||||
if let Some(file_name) = file_name.to_str() {
|
&& let Some(file_name) = file_name.to_str()
|
||||||
if let Some(game) = game_db.get_mut_game_by_id(file_name) {
|
&& let Some(game) = game_db.get_mut_game_by_id(file_name)
|
||||||
|
{
|
||||||
if installed {
|
if installed {
|
||||||
log::debug!("Game is installed: {game}");
|
log::debug!("Set {game} to installed");
|
||||||
} else {
|
} else {
|
||||||
log::error!("Game is missing: {game}");
|
log::debug!("Set {game} to uninstalled");
|
||||||
}
|
}
|
||||||
game.installed = installed;
|
game.installed = installed;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -213,16 +212,15 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
|
|||||||
|
|
||||||
// update game_db with installed games from real game directory
|
// update game_db with installed games from real game directory
|
||||||
entries.into_iter().for_each(|entry| {
|
entries.into_iter().for_each(|entry| {
|
||||||
if let Ok(entry) = entry {
|
if let Ok(entry) = entry
|
||||||
if let Ok(path_type) = entry.file_type() {
|
&& let Ok(path_type) = entry.file_type()
|
||||||
if path_type.is_dir() {
|
&& path_type.is_dir()
|
||||||
|
{
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
if path.join("version.ini").exists() {
|
if path.join("version.ini").exists() {
|
||||||
set_game_install_state_from_path(&mut game_db, &path, true);
|
set_game_install_state_from_path(&mut game_db, &path, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Err(e) = app_handle.emit("games-list-updated", Some(game_db.all_games())) {
|
if let Err(e) = app_handle.emit("games-list-updated", Some(game_db.all_games())) {
|
||||||
|
Reference in New Issue
Block a user