Implement encoding for Windows-invalid characters in syncback metadata file names across CSV, Lua, and TXT handlers. Updated file name generation to conditionally encode names based on the presence of invalid characters.

This commit is contained in:
Joe 2025-12-28 22:43:21 -06:00
parent 81f72681c6
commit 8c776c09b3
3 changed files with 21 additions and 3 deletions

View file

@ -10,6 +10,7 @@ use rbx_dom_weak::{types::Variant, ustr};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
path_encoding::encode_path_name,
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot}, snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot}, syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot},
}; };
@ -109,8 +110,13 @@ pub fn syncback_csv<'sync>(
if !meta.is_empty() { if !meta.is_empty() {
let parent = snapshot.path.parent_err()?; let parent = snapshot.path.parent_err()?;
let meta_name = if snapshot.encode_windows_invalid_chars() {
encode_path_name(&new_inst.name)
} else {
new_inst.name.clone()
};
fs_snapshot.add_file( fs_snapshot.add_file(
parent.join(format!("{}.meta.json", new_inst.name)), parent.join(format!("{}.meta.json", meta_name)),
crate::json::to_vec_pretty_sorted(&meta).context("cannot serialize metadata")?, crate::json::to_vec_pretty_sorted(&meta).context("cannot serialize metadata")?,
) )
} }

View file

@ -8,6 +8,7 @@ use rbx_dom_weak::{
}; };
use crate::{ use crate::{
path_encoding::encode_path_name,
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot}, snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot}, syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot},
}; };
@ -158,8 +159,13 @@ pub fn syncback_lua<'sync>(
if !meta.is_empty() { if !meta.is_empty() {
let parent_location = snapshot.path.parent_err()?; let parent_location = snapshot.path.parent_err()?;
let meta_name = if snapshot.encode_windows_invalid_chars() {
encode_path_name(&new_inst.name)
} else {
new_inst.name.clone()
};
fs_snapshot.add_file( fs_snapshot.add_file(
parent_location.join(format!("{}.meta.json", new_inst.name)), parent_location.join(format!("{}.meta.json", meta_name)),
crate::json::to_vec_pretty_sorted(&meta).context("cannot serialize metadata")?, crate::json::to_vec_pretty_sorted(&meta).context("cannot serialize metadata")?,
); );
} }

View file

@ -6,6 +6,7 @@ use rbx_dom_weak::types::Variant;
use rbx_dom_weak::ustr; use rbx_dom_weak::ustr;
use crate::{ use crate::{
path_encoding::encode_path_name,
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot}, snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot},
syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot}, syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot},
}; };
@ -58,8 +59,13 @@ pub fn syncback_txt<'sync>(
if !meta.is_empty() { if !meta.is_empty() {
let parent = snapshot.path.parent_err()?; let parent = snapshot.path.parent_err()?;
let meta_name = if snapshot.encode_windows_invalid_chars() {
encode_path_name(&new_inst.name)
} else {
new_inst.name.clone()
};
fs_snapshot.add_file( fs_snapshot.add_file(
parent.join(format!("{}.meta.json", new_inst.name)), parent.join(format!("{}.meta.json", meta_name)),
crate::json::to_vec_pretty_sorted(&meta).context("could not serialize metadata")?, crate::json::to_vec_pretty_sorted(&meta).context("could not serialize metadata")?,
); );
} }