mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-24 06:35:39 +00:00
Implement Syncback to support converting Roblox files to a Rojo project (#937)
This is a very large commit. Consider checking the linked PR for more information.
This commit is contained in:
@@ -3,7 +3,10 @@ use std::path::Path;
|
||||
use anyhow::Context;
|
||||
use memofs::Vfs;
|
||||
|
||||
use crate::snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot};
|
||||
use crate::{
|
||||
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
|
||||
syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot},
|
||||
};
|
||||
|
||||
#[profiling::function]
|
||||
pub fn snapshot_rbxm(
|
||||
@@ -39,6 +42,24 @@ pub fn snapshot_rbxm(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn syncback_rbxm<'sync>(
|
||||
snapshot: &SyncbackSnapshot<'sync>,
|
||||
) -> anyhow::Result<SyncbackReturn<'sync>> {
|
||||
let inst = snapshot.new_inst();
|
||||
|
||||
// Long-term, we probably want to have some logic for if this contains a
|
||||
// script. That's a future endeavor though.
|
||||
let mut serialized = Vec::new();
|
||||
rbx_binary::to_writer(&mut serialized, snapshot.new_tree(), &[inst.referent()])
|
||||
.context("failed to serialize new rbxm")?;
|
||||
|
||||
Ok(SyncbackReturn {
|
||||
fs_snapshot: FsSnapshot::new().with_added_file(&snapshot.path, serialized),
|
||||
children: Vec::new(),
|
||||
removed_children: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user