diff --git a/server/src/project.rs b/server/src/project.rs index d99d3f15..b5477d77 100644 --- a/server/src/project.rs +++ b/server/src/project.rs @@ -40,7 +40,7 @@ enum SourceProjectNode { impl SourceProjectNode { pub fn into_project_node(self, project_file_location: &Path) -> ProjectNode { match self { - SourceProjectNode::Instance { class_name, mut children, properties, .. } => { + SourceProjectNode::Instance { class_name, mut children, properties, ignore_unknown } => { let mut new_children = HashMap::new(); for (node_name, node) in children.drain() { @@ -51,6 +51,9 @@ impl SourceProjectNode { class_name, children: new_children, properties, + config: InstanceProjectNodeConfig { + ignore_unknown, + }, }) }, SourceProjectNode::SyncPoint { path: source_path } => { @@ -126,6 +129,11 @@ pub struct ProjectInitError; #[fail(display = "Project save error")] pub struct ProjectSaveError; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct InstanceProjectNodeConfig { + pub ignore_unknown: bool, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(tag = "type")] pub enum ProjectNode { @@ -139,7 +147,7 @@ pub struct InstanceProjectNode { pub class_name: String, pub children: HashMap, pub properties: HashMap, - // ignore_unknown: bool, + pub config: InstanceProjectNodeConfig, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] diff --git a/server/src/rbx_session.rs b/server/src/rbx_session.rs index 119965ea..97bb6b50 100644 --- a/server/src/rbx_session.rs +++ b/server/src/rbx_session.rs @@ -9,7 +9,7 @@ use std::{ use rbx_tree::{RbxTree, RbxValue, RbxId}; use crate::{ - project::{Project, ProjectNode, InstanceProjectNode}, + project::{Project, ProjectNode, InstanceProjectNode, InstanceProjectNodeConfig}, message_queue::MessageQueue, imfs::{Imfs, ImfsItem, ImfsFile}, path_map::PathMap, @@ -19,6 +19,7 @@ use crate::{ pub struct RbxSession { tree: RbxTree, path_map: PathMap, + config_map: HashMap, message_queue: Arc>, imfs: Arc>, project: Arc, @@ -31,15 +32,17 @@ impl RbxSession { message_queue: Arc>, ) -> RbxSession { let mut path_map = PathMap::new(); + let mut config_map = HashMap::new(); let tree = { let temp_imfs = imfs.lock().unwrap(); - construct_initial_tree(&project, &temp_imfs, &mut path_map) + construct_initial_tree(&project, &temp_imfs, &mut path_map, &mut config_map) }; RbxSession { tree, path_map, + config_map, message_queue, imfs, project, @@ -60,7 +63,7 @@ impl RbxSession { let snapshot = snapshot_instances_from_imfs(&imfs, &closest_path) .expect("Could not generate instance snapshot"); - reconcile_subtree(&mut self.tree, instance_id, &snapshot, &mut self.path_map, &mut changes); + reconcile_subtree(&mut self.tree, instance_id, &snapshot, &mut self.path_map, &mut self.config_map, &mut changes); } if !changes.is_empty() { @@ -124,17 +127,23 @@ impl RbxSession { pub fn get_tree(&self) -> &RbxTree { &self.tree } + + pub fn get_config_map(&self) -> &HashMap { + &self.config_map + } } pub fn construct_oneoff_tree(project: &Project, imfs: &Imfs) -> RbxTree { let mut path_map = PathMap::new(); - construct_initial_tree(project, imfs, &mut path_map) + let mut config_map = HashMap::new(); + construct_initial_tree(project, imfs, &mut path_map, &mut config_map) } fn construct_initial_tree( project: &Project, imfs: &Imfs, path_map: &mut PathMap, + config_map: &mut HashMap, ) -> RbxTree { let snapshot = construct_project_node( imfs, @@ -143,7 +152,7 @@ fn construct_initial_tree( ); let mut changes = InstanceChanges::default(); - let tree = reify_root(&snapshot, path_map, &mut changes); + let tree = reify_root(&snapshot, path_map, config_map, &mut changes); tree } @@ -185,6 +194,7 @@ fn construct_instance_node<'a>( properties: HashMap::new(), children, source_path: None, + config: Some(project_node.config.clone()), } } @@ -243,6 +253,7 @@ fn snapshot_instances_from_imfs<'a>(imfs: &'a Imfs, imfs_path: &Path) -> Option< properties, children: Vec::new(), source_path: Some(file.path.clone()), + config: None, }) }, ImfsItem::Directory(directory) => { @@ -257,6 +268,7 @@ fn snapshot_instances_from_imfs<'a>(imfs: &'a Imfs, imfs_path: &Path) -> Option< properties: HashMap::new(), children: Vec::new(), source_path: Some(directory.path.clone()), + config: None, } }; diff --git a/server/src/rbx_snapshot.rs b/server/src/rbx_snapshot.rs index f81161d7..842c3f6c 100644 --- a/server/src/rbx_snapshot.rs +++ b/server/src/rbx_snapshot.rs @@ -7,7 +7,10 @@ use std::{ use rbx_tree::{RbxTree, RbxId, RbxInstance, RbxValue}; -use crate::path_map::PathMap; +use crate::{ + path_map::PathMap, + project::InstanceProjectNodeConfig, +}; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct InstanceChanges { @@ -28,11 +31,13 @@ pub struct RbxSnapshotInstance<'a> { pub properties: HashMap, pub children: Vec>, pub source_path: Option, + pub config: Option, } pub fn reify_root( snapshot: &RbxSnapshotInstance, path_map: &mut PathMap, + config_map: &mut HashMap, changes: &mut InstanceChanges, ) -> RbxTree { let instance = reify_core(snapshot); @@ -43,10 +48,14 @@ pub fn reify_root( path_map.insert(source_path.clone(), root_id); } + if let Some(config) = &snapshot.config { + config_map.insert(root_id, config.clone()); + } + changes.added.insert(root_id); for child in &snapshot.children { - reify_subtree(child, &mut tree, root_id, path_map, changes); + reify_subtree(child, &mut tree, root_id, path_map, config_map, changes); } tree @@ -57,6 +66,7 @@ pub fn reify_subtree( tree: &mut RbxTree, parent_id: RbxId, path_map: &mut PathMap, + config_map: &mut HashMap, changes: &mut InstanceChanges, ) { let instance = reify_core(snapshot); @@ -66,10 +76,14 @@ pub fn reify_subtree( path_map.insert(source_path.clone(), id); } + if let Some(config) = &snapshot.config { + config_map.insert(id, config.clone()); + } + changes.added.insert(id); for child in &snapshot.children { - reify_subtree(child, tree, id, path_map, changes); + reify_subtree(child, tree, id, path_map, config_map, changes); } } @@ -78,13 +92,14 @@ pub fn reconcile_subtree( id: RbxId, snapshot: &RbxSnapshotInstance, path_map: &mut PathMap, + config_map: &mut HashMap, changes: &mut InstanceChanges, ) { if reconcile_instance_properties(tree.get_instance_mut(id).unwrap(), snapshot) { changes.updated.insert(id); } - reconcile_instance_children(tree, id, snapshot, path_map, changes); + reconcile_instance_children(tree, id, snapshot, path_map, config_map, changes); } fn reify_core(snapshot: &RbxSnapshotInstance) -> RbxInstance { @@ -165,6 +180,7 @@ fn reconcile_instance_children( id: RbxId, snapshot: &RbxSnapshotInstance, path_map: &mut PathMap, + config_map: &mut HashMap, changes: &mut InstanceChanges, ) { let children_ids = tree.get_instance(id).unwrap().get_children_ids().to_vec(); @@ -195,18 +211,19 @@ fn reconcile_instance_children( } for child_snapshot in &children_to_add { - reify_subtree(child_snapshot, tree, id, path_map, changes); + reify_subtree(child_snapshot, tree, id, path_map, config_map, changes); } for child_id in &children_to_remove { if let Some(subtree) = tree.remove_instance(*child_id) { for id in subtree.iter_all_ids() { + config_map.remove(&id); changes.removed.insert(id); } } } for (child_id, child_snapshot) in &children_to_update { - reconcile_subtree(tree, *child_id, child_snapshot, path_map, changes); + reconcile_subtree(tree, *child_id, child_snapshot, path_map, config_map, changes); } } \ No newline at end of file diff --git a/server/src/web.rs b/server/src/web.rs index 1273ffff..0985a975 100644 --- a/server/src/web.rs +++ b/server/src/web.rs @@ -15,7 +15,7 @@ use rbx_tree::{RbxId, RootedRbxInstance}; use crate::{ session::Session, session_id::SessionId, - project::Project, + project::InstanceProjectNodeConfig, rbx_snapshot::InstanceChanges, }; @@ -26,7 +26,7 @@ pub struct ServerInfoResponse<'a> { pub server_version: &'a str, pub protocol_version: u64, pub root_instance_id: RbxId, - pub project: Cow<'a, Project>, + pub config_map: Cow<'a, HashMap>, } #[derive(Debug, Serialize, Deserialize)] @@ -78,7 +78,7 @@ impl Server { protocol_version: 2, session_id: self.session.session_id, root_instance_id: tree.get_root_id(), - project: Cow::Borrowed(&self.session.project), + config_map: Cow::Borrowed(rbx_session.get_config_map()), }) },