mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Refactor metadata name handling for improved clarity
- Updated comments in `json_model.rs` and `meta_file.rs` to clarify the logic for storing the real name of instances when the filesystem name differs due to slugification or deduplication. - Simplified the conditions under which the real name is preserved, ensuring better readability and understanding of the code's intent.
This commit is contained in:
parent
5a5e1a0c77
commit
f38c1f1311
2 changed files with 14 additions and 12 deletions
|
|
@ -77,10 +77,12 @@ pub fn syncback_json_model<'sync>(
|
||||||
// could have a performance cost.
|
// could have a performance cost.
|
||||||
model.schema = old_inst.metadata().schema.clone();
|
model.schema = old_inst.metadata().schema.clone();
|
||||||
model.name = old_inst.metadata().specified_name.clone();
|
model.name = old_inst.metadata().specified_name.clone();
|
||||||
} else if snapshot.needs_meta_name {
|
}
|
||||||
// New instance whose filesystem name differs from the instance name
|
// Filesystem name differs from the instance name (due to slugification
|
||||||
// (due to slugification or deduplication). Store the real name so it
|
// or deduplication). Store the real name so it survives a round-trip.
|
||||||
// survives a round-trip through the filesystem.
|
// Checked independently: old_inst may exist but lack a specified_name
|
||||||
|
// (e.g., a previously filesystem-safe name was renamed to need slugification).
|
||||||
|
if model.name.is_none() && snapshot.needs_meta_name {
|
||||||
model.name = Some(snapshot.new_inst().name.clone());
|
model.name = Some(snapshot.new_inst().name.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,10 +162,10 @@ impl AdjacentMetadata {
|
||||||
.old_inst()
|
.old_inst()
|
||||||
.and_then(|inst| inst.metadata().specified_name.clone())
|
.and_then(|inst| inst.metadata().specified_name.clone())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
// If this is a new instance and its filesystem name differs from
|
// Filesystem name differs from the instance name (due to
|
||||||
// the instance name (due to slugification or deduplication), we
|
// slugification or deduplication). Store the real name so
|
||||||
// need to specify the name in meta.json so it can be preserved.
|
// it survives a round-trip through the filesystem.
|
||||||
if snapshot.old_inst().is_none() && snapshot.needs_meta_name {
|
if snapshot.needs_meta_name {
|
||||||
Some(snapshot.new_inst().name.clone())
|
Some(snapshot.new_inst().name.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -424,10 +424,10 @@ impl DirectoryMetadata {
|
||||||
.old_inst()
|
.old_inst()
|
||||||
.and_then(|inst| inst.metadata().specified_name.clone())
|
.and_then(|inst| inst.metadata().specified_name.clone())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
// If this is a new instance and its filesystem name differs from
|
// Filesystem name differs from the instance name (due to
|
||||||
// the instance name (due to slugification or deduplication), we
|
// slugification or deduplication). Store the real name so
|
||||||
// need to specify the name in meta.json so it can be preserved.
|
// it survives a round-trip through the filesystem.
|
||||||
if snapshot.old_inst().is_none() && snapshot.needs_meta_name {
|
if snapshot.needs_meta_name {
|
||||||
Some(snapshot.new_inst().name.clone())
|
Some(snapshot.new_inst().name.clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue