Refactor change processing and metadata handling for improved clarity

- Removed the `dedup_against_dir` method from `JobThreadContext`, simplifying the slug deduplication logic during file operations.
- Streamlined the slugification process by directly assigning the slugified name without intermediate variables, enhancing readability.
- Consolidated metadata path handling in `ApiService`, improving code organization and reducing redundancy in path construction.
- Updated comments for better understanding of the changes made to slugification and metadata processing.
This commit is contained in:
Joe 2026-02-10 19:04:47 -06:00
parent 7d47fe73f6
commit 085e1ab3f5
2 changed files with 16 additions and 85 deletions

View file

@ -574,10 +574,7 @@ impl ApiService {
adds_by_parent.entry(parent_ref).or_default().push(added);
} else {
// No parent — process individually (will fail with context)
adds_by_parent
.entry(Ref::none())
.or_default()
.push(added);
adds_by_parent.entry(Ref::none()).or_default().push(added);
}
}
for (parent_ref, siblings) in &adds_by_parent {
@ -1954,8 +1951,7 @@ impl ApiService {
indexmap::IndexMap::new(),
indexmap::IndexMap::new(),
);
let meta_path =
parent_dir.join(format!("{}.meta.json5", encoded_name));
let meta_path = parent_dir.join(format!("{}.meta.json5", encoded_name));
let content = crate::json::to_vec_pretty_sorted(&meta)
.context("Failed to serialize meta")?;
self.suppress_path(&meta_path);
@ -2005,8 +2001,7 @@ impl ApiService {
indexmap::IndexMap::new(),
indexmap::IndexMap::new(),
);
let meta_path =
parent_dir.join(format!("{}.meta.json5", encoded_name));
let meta_path = parent_dir.join(format!("{}.meta.json5", encoded_name));
let content = crate::json::to_vec_pretty_sorted(&meta)
.context("Failed to serialize meta")?;
self.suppress_path(&meta_path);
@ -2061,8 +2056,7 @@ impl ApiService {
// Recursively process children
self.process_children_incremental(&unique_children, &dir_path, stats)?;
} else {
let content =
self.serialize_instance_to_model_json(added, meta_name_field)?;
let content = self.serialize_instance_to_model_json(added, meta_name_field)?;
// Use the detected file path if available (preserves .model.json
// vs .model.json5), otherwise default to .model.json5
let file_path = match &existing_format {
@ -2210,8 +2204,12 @@ impl ApiService {
self.filter_properties_for_meta(&added.class_name, &added.properties, None);
// For non-Folder classes, we need to include className
let meta =
self.build_meta_object(Some(&added.class_name), instance_name, properties, attributes);
let meta = self.build_meta_object(
Some(&added.class_name),
instance_name,
properties,
attributes,
);
let meta_path = dir_path.join("init.meta.json5");
let content = crate::json::to_vec_pretty_sorted(&meta)
.context("Failed to serialize init.meta.json5")?;