Tweak logic in RbxSession to distinguish create and update

This commit is contained in:
Lucien Greathouse
2018-12-03 18:09:01 -08:00
parent 457f3c8f54
commit fc3f750efb
2 changed files with 24 additions and 11 deletions

View File

@@ -27,6 +27,9 @@ pub enum Message {
InstancesRemoved { InstancesRemoved {
ids: Vec<RbxId>, ids: Vec<RbxId>,
}, },
InstancesUpdated {
ids: Vec<RbxId>,
},
} }
#[derive(Default)] #[derive(Default)]

View File

@@ -40,26 +40,36 @@ impl RbxSession {
} }
} }
fn path_created_or_updated(&mut self, path: &Path) {
if let Some(instance_id) = self.path_id_tree.get(path) {
// TODO: Replace instance with ID `instance_id` with new instance
}
// TODO: Crawl up path to find first node represented in the tree or a
// sync point root. That path immediately before we find an existing
// node should be read into the tree.
}
pub fn path_created(&mut self, path: &Path) { pub fn path_created(&mut self, path: &Path) {
info!("Path created: {}", path.display()); info!("Path created: {}", path.display());
self.path_updated(path); self.path_created_or_updated(path);
} }
pub fn path_updated(&mut self, path: &Path) { pub fn path_updated(&mut self, path: &Path) {
info!("Path updated: {}", path.display()); info!("Path updated: {}", path.display());
let imfs = self.imfs.lock().unwrap(); {
let imfs = self.imfs.lock().unwrap();
// If the path doesn't exist or it's a directory, we don't care if it // If the path doesn't exist or it's a directory, we don't care if it
// updated // updated
let file = match imfs.get(path) { match imfs.get(path) {
Some(ImfsItem::Directory(_)) | None => return, Some(ImfsItem::Directory(_)) | None => return,
Some(ImfsItem::File(file)) => file, Some(ImfsItem::File(_)) => {},
}; }
}
// TODO: Crawl up path to find first node represented in the tree or a self.path_created_or_updated(path);
// sync point root. That path immediately before we find an existing
// node should be read into the tree.
} }
pub fn path_removed(&mut self, path: &Path) { pub fn path_removed(&mut self, path: &Path) {