From 33dd0f5ed1a06cf9c4de1af49f2f9153e1b6722e Mon Sep 17 00:00:00 2001 From: astrid Date: Tue, 24 Feb 2026 21:53:53 +0100 Subject: [PATCH] fix: derive adjacent meta path from snapshot path, not instance name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a script/txt/csv child is renamed by name_for_inst (e.g. "Init" → "_Init.luau"), the adjacent meta file must follow the same name. All three callers were using the Roblox instance name to construct the meta path, producing "Init.meta.json" instead of "_Init.meta.json" — which collides with the parent directory's "init.meta.json" on case-insensitive file systems. Fix by deriving the meta stem from the first dot-segment of the snapshot path file name, which already holds the resolved name. Co-Authored-By: Claude Sonnet 4.6 --- src/snapshot_middleware/csv.rs | 7 ++++++- src/snapshot_middleware/lua.rs | 15 ++++++--------- src/snapshot_middleware/txt.rs | 7 ++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/snapshot_middleware/csv.rs b/src/snapshot_middleware/csv.rs index 18fa1424..16d97329 100644 --- a/src/snapshot_middleware/csv.rs +++ b/src/snapshot_middleware/csv.rs @@ -109,8 +109,13 @@ pub fn syncback_csv<'sync>( if !meta.is_empty() { let parent = snapshot.path.parent_err()?; + let meta_stem = snapshot.path + .file_name() + .and_then(|n| n.to_str()) + .map(|s| s.split('.').next().unwrap_or(s)) + .unwrap_or_else(|| new_inst.name.as_str()); fs_snapshot.add_file( - parent.join(format!("{}.meta.json", new_inst.name)), + parent.join(format!("{meta_stem}.meta.json")), serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?, ) } diff --git a/src/snapshot_middleware/lua.rs b/src/snapshot_middleware/lua.rs index b777fbfe..c6ef07ae 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -158,16 +158,13 @@ pub fn syncback_lua<'sync>( if !meta.is_empty() { let parent_location = snapshot.path.parent_err()?; - let instance_name = &snapshot.new_inst().name; - let slugified; - let meta_name = if crate::syncback::validate_file_name(instance_name).is_err() { - slugified = crate::syncback::slugify_name(instance_name); - &slugified - } else { - instance_name - }; + let meta_stem = snapshot.path + .file_name() + .and_then(|n| n.to_str()) + .map(|s| s.split('.').next().unwrap_or(s)) + .unwrap_or_else(|| snapshot.new_inst().name.as_str()); fs_snapshot.add_file( - parent_location.join(format!("{}.meta.json", meta_name)), + parent_location.join(format!("{meta_stem}.meta.json")), serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?, ); } diff --git a/src/snapshot_middleware/txt.rs b/src/snapshot_middleware/txt.rs index c56aacdd..a4cf9d9c 100644 --- a/src/snapshot_middleware/txt.rs +++ b/src/snapshot_middleware/txt.rs @@ -58,8 +58,13 @@ pub fn syncback_txt<'sync>( if !meta.is_empty() { let parent = snapshot.path.parent_err()?; + let meta_stem = snapshot.path + .file_name() + .and_then(|n| n.to_str()) + .map(|s| s.split('.').next().unwrap_or(s)) + .unwrap_or_else(|| new_inst.name.as_str()); fs_snapshot.add_file( - parent.join(format!("{}.meta.json", new_inst.name)), + parent.join(format!("{meta_stem}.meta.json")), serde_json::to_vec_pretty(&meta).context("could not serialize metadata")?, ); }