mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Tweak logic in RbxSession to distinguish create and update
This commit is contained in:
@@ -27,6 +27,9 @@ pub enum Message {
|
|||||||
InstancesRemoved {
|
InstancesRemoved {
|
||||||
ids: Vec<RbxId>,
|
ids: Vec<RbxId>,
|
||||||
},
|
},
|
||||||
|
InstancesUpdated {
|
||||||
|
ids: Vec<RbxId>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user