From e196a2a27fbc9d421c8ad5b7e45dc92a7d38181c Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Thu, 28 Mar 2019 18:03:43 -0700 Subject: [PATCH] Attach a 'source_id' property to snapshots --- server/src/rbx_snapshot.rs | 6 ++++++ server/src/snapshot_reconciler.rs | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/server/src/rbx_snapshot.rs b/server/src/rbx_snapshot.rs index 9f9be279..64092f6b 100644 --- a/server/src/rbx_snapshot.rs +++ b/server/src/rbx_snapshot.rs @@ -184,6 +184,7 @@ pub fn snapshot_project_node<'source>( Some(path) => snapshot_imfs_path(context, imfs, &path, Some(instance_name.clone()))?, None => match &node.class_name { Some(_class_name) => Some(RbxSnapshotInstance { + source_id: None, name: instance_name.clone(), // 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() } else { RbxSnapshotInstance { + source_id: None, class_name: Cow::Borrowed("Folder"), name: snapshot_name, properties: HashMap::new(), @@ -417,6 +419,7 @@ fn snapshot_lua_file<'source>( })?; Ok(Some(RbxSnapshotInstance { + source_id: None, name: Cow::Borrowed(instance_name), class_name: Cow::Borrowed(class_name), properties: hashmap! { @@ -456,6 +459,7 @@ fn snapshot_txt_file<'source>( })?; Ok(Some(RbxSnapshotInstance { + source_id: None, name: Cow::Borrowed(instance_name), class_name: Cow::Borrowed("StringValue"), properties: hashmap! { @@ -490,6 +494,7 @@ fn snapshot_csv_file<'source>( .expect("Could not encode JSON for localization table"); Ok(Some(RbxSnapshotInstance { + source_id: None, name: Cow::Borrowed(instance_name), class_name: Cow::Borrowed("LocalizationTable"), properties: hashmap! { @@ -581,6 +586,7 @@ impl JsonModelInstance { .collect(); RbxSnapshotInstance { + source_id: None, name: Cow::Owned(self.name), class_name: Cow::Owned(self.class_name), properties: self.properties, diff --git a/server/src/snapshot_reconciler.rs b/server/src/snapshot_reconciler.rs index 05defc92..338dbbca 100644 --- a/server/src/snapshot_reconciler.rs +++ b/server/src/snapshot_reconciler.rs @@ -18,7 +18,7 @@ use crate::{ rbx_session::MetadataPerInstance, }; -pub struct ReconcilerContext<'a> { +struct ReconcilerContext<'a> { instance_per_path: &'a mut PathMap>, metadata_per_instance: &'a mut HashMap, changes: &'a mut InstanceChanges, @@ -75,7 +75,7 @@ impl InstanceChanges { pub struct RbxSnapshotInstance<'a> { /// If this snapshot came from a place that has IDs, this is the ID that /// this snapshot should be associated with. - // pub source_id: Option, + pub source_id: Option, pub name: Cow<'a, str>, pub class_name: Cow<'a, str>, pub properties: HashMap, @@ -90,7 +90,7 @@ impl<'a> RbxSnapshotInstance<'a> { .collect(); RbxSnapshotInstance { - // source_id: self.source_id, + source_id: self.source_id, name: Cow::Owned(self.name.clone().into_owned()), class_name: Cow::Owned(self.class_name.clone().into_owned()), properties: self.properties.clone(), @@ -121,7 +121,7 @@ pub fn snapshot_from_tree(tree: &RbxTree, id: RbxId) -> Option