forked from rojo-rbx/rojo
fix: derive adjacent meta path from snapshot path, not instance name
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 <noreply@anthropic.com>
This commit is contained in:
@@ -109,8 +109,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_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(
|
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")?,
|
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,16 +158,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 instance_name = &snapshot.new_inst().name;
|
let meta_stem = snapshot.path
|
||||||
let slugified;
|
.file_name()
|
||||||
let meta_name = if crate::syncback::validate_file_name(instance_name).is_err() {
|
.and_then(|n| n.to_str())
|
||||||
slugified = crate::syncback::slugify_name(instance_name);
|
.map(|s| s.split('.').next().unwrap_or(s))
|
||||||
&slugified
|
.unwrap_or_else(|| snapshot.new_inst().name.as_str());
|
||||||
} else {
|
|
||||||
instance_name
|
|
||||||
};
|
|
||||||
fs_snapshot.add_file(
|
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")?,
|
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,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_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(
|
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")?,
|
serde_json::to_vec_pretty(&meta).context("could not serialize metadata")?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user