diff --git a/unity_hub_lib/src/hub.rs b/unity_hub_lib/src/hub.rs index 968f95d..33b09da 100644 --- a/unity_hub_lib/src/hub.rs +++ b/unity_hub_lib/src/hub.rs @@ -2,6 +2,7 @@ use crate::{config::Configuration, unity_editor::UnityEditor, unity_project::Uni use dpc_pariter::IteratorExt; use std::{path::PathBuf, process::Command}; use walkdir::WalkDir; +use std::collections::HashSet; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Hub { @@ -20,6 +21,12 @@ impl Hub { } pub fn update_projects_info(&mut self) { + let mut registry = UnityProject::get_projects_from_registry() + .into_iter() + .filter(|p| !self.projects.contains(p)) + .collect(); + self.projects.append(&mut registry); + self.projects = self.projects.iter().cloned().collect::>().into_iter().collect(); self.projects.iter_mut().for_each(|project| { project.update_info(); }); diff --git a/unity_hub_lib/src/unity_project.rs b/unity_hub_lib/src/unity_project.rs index ecd1ccc..0c087ac 100644 --- a/unity_hub_lib/src/unity_project.rs +++ b/unity_hub_lib/src/unity_project.rs @@ -2,7 +2,7 @@ use std::{ops::Sub, path::Path, str}; use crate::consts; -#[derive(Debug, Serialize, Deserialize, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone, Hash, Eq)] pub struct UnityProject { pub path: String, pub title: String, @@ -12,6 +12,7 @@ pub struct UnityProject { pub edit_time: std::time::SystemTime, } + impl PartialEq for UnityProject { fn eq(&self, other: &Self) -> bool { self.path == other.path