Add automatic dedup suffix stripping to enhance syncback functionality

- Introduced a new plan to automatically strip `~N` dedup suffixes from filenames during forward sync, eliminating the need for redundant `.meta.json5` files.
- Implemented the `strip_dedup_suffix()` utility in `dedup_suffix.rs` to handle suffix removal.
- Updated `file_name_for_path()` and `get_dir_middleware()` to utilize the new stripping functionality.
- Modified syncback logic to skip writing meta `name` fields for dedup-only cases, ensuring cleaner instance naming.
- Enhanced existing tests and added new tests to cover the updated dedup behavior, ensuring robustness and correctness.

These changes aim to streamline the handling of deduplicated instances, improving overall system efficiency and clarity in naming conventions.
This commit is contained in:
Joe 2026-02-19 01:15:28 -06:00
parent 17d52e3edf
commit 7d0232c430
19 changed files with 269 additions and 84 deletions

View file

@ -68,6 +68,7 @@ gen_build_tests! {
meta_name_override,
model_json_name_override,
dedup_suffix_with_meta,
dedup_suffix_auto_strip,
init_meta_name_override,
reserved_name_override,
}

View file

@ -1067,8 +1067,8 @@ fn edit_dedup_file_with_meta() {
});
}
/// Test 29: Create Foo~1.luau with NO meta. Instance name should be
/// literally "Foo~1" -- tilde is NOT parsed as dedup marker.
/// Test 29: Create Foo~1.luau with NO meta. Forward sync strips the ~1
/// dedup suffix, so the instance name should be "Foo".
#[test]
fn dedup_file_without_meta_uses_stem() {
run_serve_test("connected_slugify", |session, mut redactions| {

View file

@ -7732,17 +7732,12 @@ fn add_same_named_folders_deduplicates() {
data_dedup.display()
);
// The dedup'd directory should have a meta with name: "Data"
// Dedup-only: no meta file needed. Forward sync strips ~N automatically.
let dedup_meta = data_dedup.join("init.meta.json5");
assert!(
dedup_meta.exists(),
"Data~2/init.meta.json5 should exist for name override"
);
let meta_content = fs::read_to_string(&dedup_meta).unwrap();
assert!(
meta_content.contains("\"Data\""),
"Dedup meta should contain name \"Data\", got: {}",
meta_content
!dedup_meta.exists(),
"Data~2/init.meta.json5 should NOT exist: forward sync strips ~N, got file at {}",
dedup_meta.display()
);
// Each directory should have its own child script