mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 22:11:38 +00:00
Tidy up path metadata, entry API, begin implementing
This commit is contained in:
parent
1d412cf0d5
commit
dcac9773fb
4 changed files with 21 additions and 12 deletions
|
|
@ -129,4 +129,15 @@ impl<'a, T> Entry<'a, T> {
|
|||
children: HashSet::new(),
|
||||
}).value
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Entry<'a, T>
|
||||
where T: Default
|
||||
{
|
||||
pub fn or_default(self) -> &'a mut T {
|
||||
&mut self.internal.or_insert(PathMapNode {
|
||||
value: Default::default(),
|
||||
children: HashSet::new(),
|
||||
}).value
|
||||
}
|
||||
}
|
||||
|
|
@ -23,9 +23,9 @@ const INIT_SCRIPT: &str = "init.lua";
|
|||
const INIT_SERVER_SCRIPT: &str = "init.server.lua";
|
||||
const INIT_CLIENT_SCRIPT: &str = "init.client.lua";
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct MetadataPerPath {
|
||||
pub instance_id: RbxId,
|
||||
pub instance_id: Option<RbxId>,
|
||||
pub instance_name: Option<String>,
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,8 @@ impl RbxSession {
|
|||
trace!("Snapshotting path {}", path_to_snapshot.display());
|
||||
|
||||
let path_metadata = self.metadata_per_path.get(&path_to_snapshot).unwrap();
|
||||
let instance_id = path_metadata.instance_id;
|
||||
let instance_id = path_metadata.instance_id
|
||||
.expect("Instance did not exist in tree");
|
||||
|
||||
// If this instance is a sync point, pull its name out of our
|
||||
// per-path metadata store.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use maplit::hashmap;
|
||||
use rbx_tree::{RbxId, RbxTree, RbxValue, RbxInstanceProperties};
|
||||
use rbx_tree::{RbxTree, RbxValue, RbxInstanceProperties};
|
||||
use failure::Fail;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -141,11 +141,8 @@ fn snapshot_sync_point_node<'source>(
|
|||
};
|
||||
|
||||
// Otherwise, we can log the name of the sync point we just snapshotted.
|
||||
// TODO: Use entry API
|
||||
metadata.metadata_per_path.insert(node.path.to_owned(), MetadataPerPath {
|
||||
instance_id: RbxId::new(),
|
||||
instance_name: Some(snapshot.name.clone().into_owned()),
|
||||
});
|
||||
let path_meta = metadata.metadata_per_path.entry(node.path.to_owned()).or_default();
|
||||
path_meta.instance_name = Some(snapshot.name.clone().into_owned());
|
||||
|
||||
Ok(Some(snapshot))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ pub fn reify_root(
|
|||
// TODO: Use entry API instead?
|
||||
// metadata_per_path.entry()
|
||||
metadata_per_path.insert(source_path.clone(), MetadataPerPath {
|
||||
instance_id: root_id,
|
||||
instance_id: Some(root_id),
|
||||
instance_name: None,
|
||||
});
|
||||
}
|
||||
|
|
@ -129,8 +129,8 @@ pub fn reify_subtree(
|
|||
let id = tree.insert_instance(instance, parent_id);
|
||||
|
||||
if let Some(source_path) = &snapshot.source_path {
|
||||
// TODO: use entry API
|
||||
// metadata_per_path.insert(source_path.clone(), id);
|
||||
// TODO: Entry API
|
||||
// let metadata = metadata_per_path.entry(source_path.clone(), id);
|
||||
}
|
||||
|
||||
if let Some(metadata) = &snapshot.metadata {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue