From f54367e5e04fb63b9b470319b51ce251c47981e8 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 28 Dec 2025 23:04:59 -0600 Subject: [PATCH] Refactor metadata file name generation in `read_and_apply_all` to use the file stem from the actual path, ensuring correct handling of encoded characters for Windows-invalid filenames. --- src/snapshot_middleware/meta_file.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/snapshot_middleware/meta_file.rs b/src/snapshot_middleware/meta_file.rs index 84ca9a80..eef96bff 100644 --- a/src/snapshot_middleware/meta_file.rs +++ b/src/snapshot_middleware/meta_file.rs @@ -49,11 +49,18 @@ impl AdjacentMetadata { pub fn read_and_apply_all( vfs: &Vfs, path: &Path, - name: &str, + _name: &str, snapshot: &mut InstanceSnapshot, ) -> anyhow::Result<()> { - let meta_path_json = path.with_file_name(format!("{name}.meta.json")); - let meta_path_jsonc = path.with_file_name(format!("{name}.meta.jsonc")); + // Use the file stem from the actual path (which has encoded chars) + // rather than the decoded name, so meta files are found correctly + // when encodeWindowsInvalidChars is enabled. + let file_stem = path + .file_stem() + .and_then(|s| s.to_str()) + .unwrap_or(""); + let meta_path_json = path.with_file_name(format!("{file_stem}.meta.json")); + let meta_path_jsonc = path.with_file_name(format!("{file_stem}.meta.jsonc")); if let Some(meta_contents) = vfs.read(&meta_path_json).with_not_found()? { let mut metadata = Self::from_slice(&meta_contents, meta_path_json.clone())?;