mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
feat: auto-resolve init-name conflicts during syncback
When a child instance has a Roblox name that would produce a filesystem name of "init" (case-insensitive), syncback now automatically prefixes it with '_' (e.g. "Init" → "_Init.luau") instead of erroring. The corresponding meta.json writes the original name via the `name` property so Rojo can restore it on the next snapshot. The sibling dedup check is updated to use actual on-disk names for existing children and the resolved (init-prefixed) name for new ones, so genuine collisions still error while false positives from the `name` property are avoided. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -154,11 +154,18 @@ impl AdjacentMetadata {
|
||||
.old_inst()
|
||||
.and_then(|inst| inst.metadata().specified_name.clone())
|
||||
.or_else(|| {
|
||||
// If this is a new instance and its name is invalid for the filesystem,
|
||||
// we need to specify the name in meta.json so it can be preserved
|
||||
// Write name when the filesystem path doesn't match the
|
||||
// instance name (invalid chars or init-prefix).
|
||||
if snapshot.old_inst().is_none() {
|
||||
let instance_name = &snapshot.new_inst().name;
|
||||
if validate_file_name(instance_name).is_err() {
|
||||
let fs_stem = path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.map(|s| s.split('.').next().unwrap_or(s))
|
||||
.unwrap_or("");
|
||||
if validate_file_name(instance_name).is_err()
|
||||
|| fs_stem != instance_name.as_str()
|
||||
{
|
||||
Some(instance_name.clone())
|
||||
} else {
|
||||
None
|
||||
@@ -421,11 +428,17 @@ impl DirectoryMetadata {
|
||||
.old_inst()
|
||||
.and_then(|inst| inst.metadata().specified_name.clone())
|
||||
.or_else(|| {
|
||||
// If this is a new instance and its name is invalid for the filesystem,
|
||||
// we need to specify the name in meta.json so it can be preserved
|
||||
// Write name when the directory name doesn't match the
|
||||
// instance name (invalid chars or init-prefix).
|
||||
if snapshot.old_inst().is_none() {
|
||||
let instance_name = &snapshot.new_inst().name;
|
||||
if validate_file_name(instance_name).is_err() {
|
||||
let fs_name = path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.unwrap_or("");
|
||||
if validate_file_name(instance_name).is_err()
|
||||
|| fs_name != instance_name.as_str()
|
||||
{
|
||||
Some(instance_name.clone())
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user