Roundtrip schemas in syncback (#1173)

This commit is contained in:
Micah
2025-11-26 16:11:39 -08:00
committed by GitHub
parent a99e877b7c
commit a61a1bef55
64 changed files with 189 additions and 17 deletions

View File

@@ -50,6 +50,7 @@ pub fn snapshot_json_model(
instance.name = Some(name.to_owned());
let id = instance.id.take().map(RojoRef::new);
let schema = instance.schema.take();
let mut snapshot = instance
.into_snapshot()
@@ -60,7 +61,8 @@ pub fn snapshot_json_model(
.instigating_source(path)
.relevant_paths(vec![path.to_path_buf()])
.context(context)
.specified_id(id);
.specified_id(id)
.schema(schema);
Ok(Some(snapshot))
}
@@ -74,6 +76,13 @@ pub fn syncback_json_model<'sync>(
// We don't need the name on the root, but we do for children.
model.name = None;
if let Some(old_inst) = snapshot.old_inst() {
// TODO: Is it worth this being an Arc or Rc? I doubt that enough
// schemas will ever exist in one project for it to matter, but it
// could have a performance cost.
model.schema = old_inst.metadata().schema.clone();
}
Ok(SyncbackReturn {
fs_snapshot: FsSnapshot::new().with_added_file(
&snapshot.path,