diff --git a/server/src/project.rs b/server/src/project.rs index 878591c2..db33ed04 100644 --- a/server/src/project.rs +++ b/server/src/project.rs @@ -1,5 +1,5 @@ use std::{ - collections::{HashMap, HashSet}, + collections::{HashMap, HashSet, BTreeMap}, fmt, fs::{self, File}, io, @@ -128,7 +128,7 @@ fn serialize_unresolved_map(value: &HashMap, seri /// Similar to SourceProject, the structure of nodes in the project tree is /// slightly different on-disk than how we want to handle them in the rest of /// Rojo. -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] struct SourceProjectNode { #[serde(rename = "$className", skip_serializing_if = "Option::is_none")] class_name: Option, @@ -148,14 +148,14 @@ struct SourceProjectNode { path: Option, #[serde(flatten)] - children: HashMap, + children: BTreeMap, } impl SourceProjectNode { /// Consumes the SourceProjectNode and turns it into a ProjectNode. - pub fn into_project_node(mut self, project_file_location: &Path) -> ProjectNode { - let children = self.children.drain() - .map(|(key, value)| (key, value.into_project_node(project_file_location))) + pub fn into_project_node(self, project_file_location: &Path) -> ProjectNode { + let children = self.children.iter() + .map(|(key, value)| (key.clone(), value.clone().into_project_node(project_file_location))) .collect(); // Make sure that paths are absolute, transforming them by adding the @@ -264,7 +264,7 @@ pub enum ProjectSaveError { #[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)] pub struct ProjectNode { pub class_name: Option, - pub children: HashMap, + pub children: BTreeMap, pub properties: HashMap, pub ignore_unknown_instances: Option, diff --git a/server/tests/read_projects.rs b/server/tests/read_projects.rs index 63195acf..38cb5f89 100644 --- a/server/tests/read_projects.rs +++ b/server/tests/read_projects.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate lazy_static; use std::{ - collections::HashMap, + collections::{HashMap, BTreeMap}, path::{Path, PathBuf}, }; @@ -53,7 +53,7 @@ fn single_partition_game() { ..Default::default() }; - let mut replicated_storage_children = HashMap::new(); + let mut replicated_storage_children = BTreeMap::new(); replicated_storage_children.insert("Foo".to_string(), foo); let replicated_storage = ProjectNode { @@ -73,7 +73,7 @@ fn single_partition_game() { ..Default::default() }; - let mut root_children = HashMap::new(); + let mut root_children = BTreeMap::new(); root_children.insert("ReplicatedStorage".to_string(), replicated_storage); root_children.insert("HttpService".to_string(), http_service);