mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 13:31:37 +00:00
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.
This commit is contained in:
parent
8c776c09b3
commit
f54367e5e0
1 changed files with 10 additions and 3 deletions
|
|
@ -49,11 +49,18 @@ impl AdjacentMetadata {
|
||||||
pub fn read_and_apply_all(
|
pub fn read_and_apply_all(
|
||||||
vfs: &Vfs,
|
vfs: &Vfs,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
name: &str,
|
_name: &str,
|
||||||
snapshot: &mut InstanceSnapshot,
|
snapshot: &mut InstanceSnapshot,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let meta_path_json = path.with_file_name(format!("{name}.meta.json"));
|
// Use the file stem from the actual path (which has encoded chars)
|
||||||
let meta_path_jsonc = path.with_file_name(format!("{name}.meta.jsonc"));
|
// 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()? {
|
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())?;
|
let mut metadata = Self::from_slice(&meta_contents, meta_path_json.clone())?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue