mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Refactor filesystem name retrieval in ref_target_path_from_tree
- Replaced the manual derivation of filesystem names with a call to `tree.filesystem_name_for(current)`, simplifying the code and improving maintainability. - This change enhances clarity by centralizing the logic for obtaining filesystem names, reducing redundancy in the function.
This commit is contained in:
parent
d3a9155e10
commit
b0f9b06cbb
1 changed files with 1 additions and 29 deletions
|
|
@ -154,35 +154,7 @@ pub fn ref_target_path_from_tree(tree: &crate::snapshot::RojoTree, target_ref: R
|
|||
None => break,
|
||||
};
|
||||
|
||||
// Derive the filesystem name for this instance.
|
||||
let fs_name = if let Some(meta) = tree.get_metadata(current) {
|
||||
if let Some(source) = &meta.instigating_source {
|
||||
match source {
|
||||
crate::snapshot::InstigatingSource::Path(_) => {
|
||||
// File-backed instance: use the filename from disk.
|
||||
source
|
||||
.path()
|
||||
.file_name()
|
||||
.and_then(|f| f.to_str())
|
||||
.unwrap_or(&inst.name)
|
||||
.to_string()
|
||||
}
|
||||
crate::snapshot::InstigatingSource::ProjectNode { .. } => {
|
||||
// Project-sourced instance: use instance name, not the
|
||||
// project file path (which would be e.g. "default.project.json5").
|
||||
inst.name.clone()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No instigating source (newly added) -- use name.
|
||||
inst.name.clone()
|
||||
}
|
||||
} else {
|
||||
// No metadata at all -- use instance name.
|
||||
inst.name.clone()
|
||||
};
|
||||
|
||||
components.push(fs_name);
|
||||
components.push(tree.filesystem_name_for(current));
|
||||
current = inst.parent();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue