diff --git a/server/src/rbx_session.rs b/server/src/rbx_session.rs index e695db04..218aa8fb 100644 --- a/server/src/rbx_session.rs +++ b/server/src/rbx_session.rs @@ -63,13 +63,18 @@ impl RbxSession { let closest_path = self.path_map.descend(root_path, path); let &instance_id = self.path_map.get(&closest_path).unwrap(); + trace!("Snapshotting path {}", closest_path.display()); + let snapshot = snapshot_instances_from_imfs(&imfs, &closest_path, &mut self.sync_point_names) .expect("Could not generate instance snapshot"); reconcile_subtree(&mut self.tree, instance_id, &snapshot, &mut self.path_map, &mut self.instance_metadata_map, &mut changes); } - if !changes.is_empty() { + if changes.is_empty() { + trace!("No instance changes triggered from file update."); + } else { + trace!("Pushing changes: {}", changes); self.message_queue.push_messages(&[changes]); } } @@ -88,7 +93,10 @@ impl RbxSession { // If the path doesn't exist or it's a directory, we don't care if it // updated match imfs.get(path) { - Some(ImfsItem::Directory(_)) | None => return, + Some(ImfsItem::Directory(_)) | None => { + trace!("Updated path was a directory, ignoring."); + return; + }, Some(ImfsItem::File(_)) => {}, } } @@ -101,7 +109,12 @@ impl RbxSession { let instance_id = match self.path_map.remove(path) { Some(id) => id, - None => return, + None => { + // TODO: init.lua files won't be in the path map, that should be + // patched up! + trace!("Path was not in path map, ignoring removal."); + return; + }, }; let removed_subtree = match self.tree.remove_instance(instance_id) { @@ -118,6 +131,8 @@ impl RbxSession { updated: HashSet::new(), }; + trace!("Pushing changes: {}", changes); + self.message_queue.push_messages(&[changes]); } diff --git a/server/src/rbx_snapshot.rs b/server/src/rbx_snapshot.rs index 55de7bbf..9cd43bb7 100644 --- a/server/src/rbx_snapshot.rs +++ b/server/src/rbx_snapshot.rs @@ -2,6 +2,7 @@ use std::{ str, borrow::Cow, collections::{HashMap, HashSet}, + fmt, path::PathBuf, }; @@ -19,6 +20,35 @@ pub struct InstanceChanges { pub updated: HashSet, } +impl fmt::Display for InstanceChanges { + fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result { + writeln!(output, "InstanceChanges {{")?; + + if !self.added.is_empty() { + writeln!(output, " Added:")?; + for id in &self.added { + writeln!(output, " {}", id)?; + } + } + + if !self.removed.is_empty() { + writeln!(output, " Removed:")?; + for id in &self.removed { + writeln!(output, " {}", id)?; + } + } + + if !self.updated.is_empty() { + writeln!(output, " Updated:")?; + for id in &self.updated { + writeln!(output, " {}", id)?; + } + } + + writeln!(output, "}}") + } +} + impl InstanceChanges { pub fn is_empty(&self) -> bool { self.added.is_empty() && self.removed.is_empty() && self.updated.is_empty() diff --git a/server/src/visualize.rs b/server/src/visualize.rs index b7cda558..97b1f294 100644 --- a/server/src/visualize.rs +++ b/server/src/visualize.rs @@ -58,7 +58,7 @@ impl<'a> fmt::Display for VisualizeRbxTree<'a> { fn visualize_rbx_node(tree: &RbxTree, id: RbxId, output: &mut fmt::Formatter) -> fmt::Result { let node = tree.get_instance(id).unwrap(); - writeln!(output, " \"{}\" [label=\"{}\"]", id, node.name)?; + writeln!(output, " \"{}\" [label=\"{} ({})\"]", id, node.name, node.class_name)?; for &child_id in node.get_children_ids() { writeln!(output, " \"{}\" -> \"{}\"", id, child_id)?;