From 5b1b5db06cd2708490fda0a1108bd06566769235 Mon Sep 17 00:00:00 2001 From: astrid Date: Wed, 25 Feb 2026 16:33:09 +0100 Subject: [PATCH] fix: derive adjacent meta stem from snapshot path, not instance name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fix used split('.').next() to get the meta stem from the snapshot path, which only takes the first dot-segment. This broke names containing dots (e.g. "Name.new" → "Name.new.luau" would produce "Name.meta.json" instead of "Name.new.meta.json"). Strip the full middleware extension (e.g. ".server.luau", ".txt") from the snapshot path filename instead. This correctly handles all cases: Name.new.luau → Name.new → Name.new.meta.json _Init.server.luau → _Init → _Init.meta.json Name.new.txt → Name.new → Name.new.meta.json Co-Authored-By: Claude Sonnet 4.6 --- src/snapshot_middleware/csv.rs | 14 +++++++++----- src/snapshot_middleware/lua.rs | 14 +++++++++----- src/snapshot_middleware/txt.rs | 14 +++++++++----- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/snapshot_middleware/csv.rs b/src/snapshot_middleware/csv.rs index 16d97329..26200591 100644 --- a/src/snapshot_middleware/csv.rs +++ b/src/snapshot_middleware/csv.rs @@ -109,11 +109,15 @@ 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()); + let meta_stem = snapshot.middleware + .and_then(|mw| { + let ext = format!(".{}", crate::syncback::extension_for_middleware(mw)); + snapshot.path.file_name() + .and_then(|n| n.to_str()) + .and_then(|s| s.strip_suffix(ext.as_str())) + .map(str::to_owned) + }) + .unwrap_or_else(|| new_inst.name.clone()); fs_snapshot.add_file( 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 c6ef07ae..4f68ef99 100644 --- a/src/snapshot_middleware/lua.rs +++ b/src/snapshot_middleware/lua.rs @@ -158,11 +158,15 @@ pub fn syncback_lua<'sync>( if !meta.is_empty() { let parent_location = 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(|| snapshot.new_inst().name.as_str()); + let meta_stem = snapshot.middleware + .and_then(|mw| { + let ext = format!(".{}", crate::syncback::extension_for_middleware(mw)); + snapshot.path.file_name() + .and_then(|n| n.to_str()) + .and_then(|s| s.strip_suffix(ext.as_str())) + .map(str::to_owned) + }) + .unwrap_or_else(|| snapshot.new_inst().name.clone()); fs_snapshot.add_file( 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 a4cf9d9c..194f4bbe 100644 --- a/src/snapshot_middleware/txt.rs +++ b/src/snapshot_middleware/txt.rs @@ -58,11 +58,15 @@ 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()); + let meta_stem = snapshot.middleware + .and_then(|mw| { + let ext = format!(".{}", crate::syncback::extension_for_middleware(mw)); + snapshot.path.file_name() + .and_then(|n| n.to_str()) + .and_then(|s| s.strip_suffix(ext.as_str())) + .map(str::to_owned) + }) + .unwrap_or_else(|| new_inst.name.clone()); fs_snapshot.add_file( parent.join(format!("{meta_stem}.meta.json")), serde_json::to_vec_pretty(&meta).context("could not serialize metadata")?,