Attach a 'source_id' property to snapshots

This commit is contained in:
Lucien Greathouse 2019-03-28 18:03:43 -07:00
parent 9050a098ab
commit e196a2a27f
2 changed files with 10 additions and 4 deletions

View file

@ -184,6 +184,7 @@ pub fn snapshot_project_node<'source>(
Some(path) => snapshot_imfs_path(context, imfs, &path, Some(instance_name.clone()))?, Some(path) => snapshot_imfs_path(context, imfs, &path, Some(instance_name.clone()))?,
None => match &node.class_name { None => match &node.class_name {
Some(_class_name) => Some(RbxSnapshotInstance { Some(_class_name) => Some(RbxSnapshotInstance {
source_id: None,
name: instance_name.clone(), name: instance_name.clone(),
// These properties are replaced later in the function to // These properties are replaced later in the function to
@ -305,6 +306,7 @@ fn snapshot_imfs_directory<'source>(
snapshot_imfs_path(context, imfs, &init_client_path, Some(snapshot_name))?.unwrap() snapshot_imfs_path(context, imfs, &init_client_path, Some(snapshot_name))?.unwrap()
} else { } else {
RbxSnapshotInstance { RbxSnapshotInstance {
source_id: None,
class_name: Cow::Borrowed("Folder"), class_name: Cow::Borrowed("Folder"),
name: snapshot_name, name: snapshot_name,
properties: HashMap::new(), properties: HashMap::new(),
@ -417,6 +419,7 @@ fn snapshot_lua_file<'source>(
})?; })?;
Ok(Some(RbxSnapshotInstance { Ok(Some(RbxSnapshotInstance {
source_id: None,
name: Cow::Borrowed(instance_name), name: Cow::Borrowed(instance_name),
class_name: Cow::Borrowed(class_name), class_name: Cow::Borrowed(class_name),
properties: hashmap! { properties: hashmap! {
@ -456,6 +459,7 @@ fn snapshot_txt_file<'source>(
})?; })?;
Ok(Some(RbxSnapshotInstance { Ok(Some(RbxSnapshotInstance {
source_id: None,
name: Cow::Borrowed(instance_name), name: Cow::Borrowed(instance_name),
class_name: Cow::Borrowed("StringValue"), class_name: Cow::Borrowed("StringValue"),
properties: hashmap! { properties: hashmap! {
@ -490,6 +494,7 @@ fn snapshot_csv_file<'source>(
.expect("Could not encode JSON for localization table"); .expect("Could not encode JSON for localization table");
Ok(Some(RbxSnapshotInstance { Ok(Some(RbxSnapshotInstance {
source_id: None,
name: Cow::Borrowed(instance_name), name: Cow::Borrowed(instance_name),
class_name: Cow::Borrowed("LocalizationTable"), class_name: Cow::Borrowed("LocalizationTable"),
properties: hashmap! { properties: hashmap! {
@ -581,6 +586,7 @@ impl JsonModelInstance {
.collect(); .collect();
RbxSnapshotInstance { RbxSnapshotInstance {
source_id: None,
name: Cow::Owned(self.name), name: Cow::Owned(self.name),
class_name: Cow::Owned(self.class_name), class_name: Cow::Owned(self.class_name),
properties: self.properties, properties: self.properties,

View file

@ -18,7 +18,7 @@ use crate::{
rbx_session::MetadataPerInstance, rbx_session::MetadataPerInstance,
}; };
pub struct ReconcilerContext<'a> { struct ReconcilerContext<'a> {
instance_per_path: &'a mut PathMap<HashSet<RbxId>>, instance_per_path: &'a mut PathMap<HashSet<RbxId>>,
metadata_per_instance: &'a mut HashMap<RbxId, MetadataPerInstance>, metadata_per_instance: &'a mut HashMap<RbxId, MetadataPerInstance>,
changes: &'a mut InstanceChanges, changes: &'a mut InstanceChanges,
@ -75,7 +75,7 @@ impl InstanceChanges {
pub struct RbxSnapshotInstance<'a> { pub struct RbxSnapshotInstance<'a> {
/// If this snapshot came from a place that has IDs, this is the ID that /// If this snapshot came from a place that has IDs, this is the ID that
/// this snapshot should be associated with. /// this snapshot should be associated with.
// pub source_id: Option<RbxId>, pub source_id: Option<RbxId>,
pub name: Cow<'a, str>, pub name: Cow<'a, str>,
pub class_name: Cow<'a, str>, pub class_name: Cow<'a, str>,
pub properties: HashMap<String, RbxValue>, pub properties: HashMap<String, RbxValue>,
@ -90,7 +90,7 @@ impl<'a> RbxSnapshotInstance<'a> {
.collect(); .collect();
RbxSnapshotInstance { RbxSnapshotInstance {
// source_id: self.source_id, source_id: self.source_id,
name: Cow::Owned(self.name.clone().into_owned()), name: Cow::Owned(self.name.clone().into_owned()),
class_name: Cow::Owned(self.class_name.clone().into_owned()), class_name: Cow::Owned(self.class_name.clone().into_owned()),
properties: self.properties.clone(), properties: self.properties.clone(),
@ -121,7 +121,7 @@ pub fn snapshot_from_tree(tree: &RbxTree, id: RbxId) -> Option<RbxSnapshotInstan
} }
Some(RbxSnapshotInstance { Some(RbxSnapshotInstance {
// source_id: Some(id), source_id: Some(id),
name: Cow::Owned(instance.name.to_owned()), name: Cow::Owned(instance.name.to_owned()),
class_name: Cow::Owned(instance.class_name.to_owned()), class_name: Cow::Owned(instance.class_name.to_owned()),
properties: instance.properties.clone(), properties: instance.properties.clone(),