Skip to content

Commit

Permalink
Use simplified filtering logic for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot committed Feb 9, 2024
1 parent 03330cf commit 0c4057f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/snapshot_middleware/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
InstanceContext, InstanceMetadata, InstanceSnapshot, InstigatingSource, PathIgnoreRule,
SyncRule,
},
syncback::{FsSnapshot, SyncbackReturn, SyncbackSnapshot},
syncback::{filter_out_property, FsSnapshot, SyncbackReturn, SyncbackSnapshot},
RojoRef,
};

Expand Down Expand Up @@ -361,14 +361,20 @@ pub fn syncback_project<'new, 'old>(

let properties = &mut node.properties;

let filtered_properties = snapshot
.get_filtered_properties(new_inst.referent(), Some(old_inst.id()))
.expect("all project nodes should exist in both trees when in queue");
for (name, value) in filtered_properties {
properties.insert(
name.to_owned(),
UnresolvedValue::from_variant(value.clone(), &new_inst.class, name),
);
for (name, value) in &new_inst.properties {
if node.path.is_some() {
if !filter_out_property(new_inst, name) {
properties.insert(
name.to_owned(),
UnresolvedValue::from_variant(value.clone(), &new_inst.class, name),
);
}
} else {
properties.insert(
name.to_owned(),
UnresolvedValue::from_variant(value.clone(), &new_inst.class, name),
);
}
}
for (child_name, child_node) in &mut node.children {
if let Some(path_node) = &child_node.path {
Expand Down
2 changes: 1 addition & 1 deletion src/syncback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use fs_snapshot::FsSnapshot;
pub use hash::*;
pub use property_filter::filter_properties;
pub use ref_properties::link_referents;
pub use snapshot::{SyncbackData, SyncbackSnapshot};
pub use snapshot::{filter_out_property, SyncbackData, SyncbackSnapshot};

pub fn syncback_loop<'old>(
vfs: &'old Vfs,
Expand Down
2 changes: 1 addition & 1 deletion src/syncback/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl<'new, 'old> SyncbackSnapshot<'new, 'old> {
}
}

fn filter_out_property(inst: &Instance, prop_name: &str) -> bool {
pub fn filter_out_property(inst: &Instance, prop_name: &str) -> bool {
// We don't need SourceAssetId.
if prop_name == "Tags" || prop_name == "Attributes" || prop_name == "SourceAssetId" {
return true;
Expand Down

0 comments on commit 0c4057f

Please sign in to comment.