Mark project file as instigating source for top-level instances

This commit is contained in:
Lucien Greathouse
2019-10-04 18:05:27 -07:00
parent 956d7e0918
commit c051153a1f
10 changed files with 39 additions and 14 deletions

View File

@@ -51,11 +51,18 @@ impl SnapshotMiddleware for SnapshotProject {
// unwrap is safe.
let mut snapshot = snapshot_project_node(&project.name, &project.tree, imfs)?.unwrap();
// If the project file updates, we want to trigger a snapshot of the
// entire project tree. We're overwriting the "instigating path" for the
// root instance of the project, since we want to snapshot the project
// file and not the snapshot's original instigating path, or else we
// won't pick up new changes from the project file.
// Setting the instigating source to the project file path is a little
// coarse.
//
// Ideally, we'd only snapshot the project file if the project file
// actually changed. Because Rojo only has the concept of one
// relevant path -> snapshot path mapping per instance, we pick the more
// conservative approach of snapshotting the project file if any
// relevant paths changed.
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
// Mark this snapshot (the root node of the project file) as being
// related to the project file.
//
// We SHOULD NOT mark the project file as a relevant path for any
// nodes that aren't roots. They'll be updated as part of the project