forked from rojo-rbx/rojo
feat: resolve duplicate sibling names with incrementing suffixes
Instead of bailing when children have duplicate filesystem names, syncback now resolves collisions by appending incrementing suffixes (e.g. Foo, Foo1, Foo2). This handles both init-renamed children and any other name collisions. Meta stem derivation is now path-based to correctly handle collision suffixes and dotted names. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -158,17 +158,21 @@ pub fn syncback_lua<'sync>(
|
||||
|
||||
if !meta.is_empty() {
|
||||
let parent_location = snapshot.path.parent_err()?;
|
||||
let instance_name = &snapshot.new_inst().name;
|
||||
let base = if crate::syncback::validate_file_name(instance_name).is_err() {
|
||||
crate::syncback::slugify_name(instance_name)
|
||||
} else {
|
||||
instance_name.clone()
|
||||
};
|
||||
let meta_stem = if base.to_lowercase() == "init" {
|
||||
format!("_{base}")
|
||||
} else {
|
||||
base
|
||||
};
|
||||
let file_name = snapshot
|
||||
.path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.unwrap_or("");
|
||||
let meta_stem = file_name
|
||||
.strip_suffix(".server.luau")
|
||||
.or_else(|| file_name.strip_suffix(".server.lua"))
|
||||
.or_else(|| file_name.strip_suffix(".client.luau"))
|
||||
.or_else(|| file_name.strip_suffix(".client.lua"))
|
||||
.or_else(|| file_name.strip_suffix(".plugin.luau"))
|
||||
.or_else(|| file_name.strip_suffix(".plugin.lua"))
|
||||
.or_else(|| file_name.strip_suffix(".luau"))
|
||||
.or_else(|| file_name.strip_suffix(".lua"))
|
||||
.unwrap_or(file_name);
|
||||
fs_snapshot.add_file(
|
||||
parent_location.join(format!("{meta_stem}.meta.json")),
|
||||
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
||||
|
||||
Reference in New Issue
Block a user