Remove InstanceSnapshotContext in favor of InstanceContext (#271)

* Drop plugin context on the floor

* Remove redirect from old context to new context

* Pass InstanceContext via & instead of &mut reference

* Re-use context value in ChangeProcessor from metadata
This commit is contained in:
Lucien Greathouse
2019-12-03 16:11:51 -08:00
committed by GitHub
parent 12df80da56
commit 948303aac8
15 changed files with 99 additions and 209 deletions

View File

@@ -14,7 +14,7 @@ use crate::{
snapshot::{
apply_patch_set, compute_patch_set, AppliedPatchSet, InstigatingSource, PatchSet, RojoTree,
},
snapshot_middleware::{snapshot_from_vfs, snapshot_project_node, InstanceSnapshotContext},
snapshot_middleware::{snapshot_from_vfs, snapshot_project_node},
vfs::{FsResultExt, Vfs, VfsEvent, VfsFetcher},
};
@@ -141,10 +141,6 @@ fn update_affected_instances<F: VfsFetcher>(
}
};
// TODO: Use persisted snapshot context struct instead of recreating it
// every time.
let mut snapshot_context = InstanceSnapshotContext::default();
// How we process a file change event depends on what created this
// file/folder in the first place.
let applied_patch_set = match instigating_source {
@@ -161,7 +157,7 @@ fn update_affected_instances<F: VfsFetcher>(
// starting at that path and use it as the source for
// our patch.
let snapshot = snapshot_from_vfs(&mut snapshot_context, &vfs, &entry)
let snapshot = snapshot_from_vfs(&metadata.context, &vfs, &entry)
.expect("snapshot failed")
.expect("snapshot did not return an instance");
@@ -188,7 +184,7 @@ fn update_affected_instances<F: VfsFetcher>(
// the project file, we snapshot the entire project node again.
let snapshot =
snapshot_project_node(&mut snapshot_context, instance_name, project_node, &vfs)
snapshot_project_node(&metadata.context, instance_name, project_node, &vfs)
.expect("snapshot failed")
.expect("snapshot did not return an instance");