Reintroduce instigating paths for snapshot middleware

This commit is contained in:
Lucien Greathouse
2019-10-04 18:36:04 -07:00
parent cb3211cf46
commit 98519da7d9
17 changed files with 36 additions and 10 deletions

View File

@@ -94,9 +94,9 @@ impl ChangeProcessor {
}; };
let snapshot = match instigating_source { let snapshot = match instigating_source {
InstigatingSource::Path(instigating_path) => { InstigatingSource::Path(path) => {
let entry = imfs let entry = imfs
.get(instigating_path) .get(path)
.expect("could not get instigating path from filesystem"); .expect("could not get instigating path from filesystem");
let snapshot = snapshot_from_imfs(&mut imfs, &entry) let snapshot = snapshot_from_imfs(&mut imfs, &entry)

View File

@@ -40,6 +40,7 @@ impl SnapshotMiddleware for SnapshotCsv {
Ok(Some(InstanceSnapshot { Ok(Some(InstanceSnapshot {
snapshot_id: None, snapshot_id: None,
metadata: InstanceMetadata { metadata: InstanceMetadata {
instigating_source: Some(entry.path().to_path_buf().into()),
relevant_paths: vec![entry.path().to_path_buf()], relevant_paths: vec![entry.path().to_path_buf()],
..Default::default() ..Default::default()
}, },

View File

@@ -44,6 +44,7 @@ impl SnapshotMiddleware for SnapshotDir {
Ok(Some(InstanceSnapshot { Ok(Some(InstanceSnapshot {
snapshot_id: None, snapshot_id: None,
metadata: InstanceMetadata { metadata: InstanceMetadata {
instigating_source: Some(entry.path().to_path_buf().into()),
relevant_paths: vec![entry.path().to_path_buf()], relevant_paths: vec![entry.path().to_path_buf()],
..Default::default() ..Default::default()
}, },

View File

@@ -52,6 +52,7 @@ impl SnapshotMiddleware for SnapshotJsonModel {
let mut snapshot = instance.core.into_snapshot(instance_name); let mut snapshot = instance.core.into_snapshot(instance_name);
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()]; snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()];
Ok(Some(snapshot)) Ok(Some(snapshot))

View File

@@ -91,6 +91,7 @@ fn snapshot_lua_file<F: ImfsFetcher>(
Ok(Some(InstanceSnapshot { Ok(Some(InstanceSnapshot {
snapshot_id: None, snapshot_id: None,
metadata: InstanceMetadata { metadata: InstanceMetadata {
instigating_source: Some(entry.path().to_path_buf().into()),
relevant_paths: vec![entry.path().to_path_buf()], relevant_paths: vec![entry.path().to_path_buf()],
..Default::default() ..Default::default()
}, },

View File

@@ -43,6 +43,7 @@ impl SnapshotMiddleware for SnapshotRbxlx {
let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, root_id); let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, root_id);
snapshot.name = Cow::Owned(instance_name); snapshot.name = Cow::Owned(instance_name);
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()]; snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()];
Ok(Some(snapshot)) Ok(Some(snapshot))

View File

@@ -49,6 +49,7 @@ impl SnapshotMiddleware for SnapshotRbxm {
if children.len() == 1 { if children.len() == 1 {
let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0]); let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0]);
snapshot.name = Cow::Owned(instance_name); snapshot.name = Cow::Owned(instance_name);
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()]; snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()];
Ok(Some(snapshot)) Ok(Some(snapshot))

View File

@@ -45,6 +45,7 @@ impl SnapshotMiddleware for SnapshotRbxmx {
if children.len() == 1 { if children.len() == 1 {
let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0]); let mut snapshot = InstanceSnapshot::from_tree(&temp_tree, children[0]);
snapshot.name = Cow::Owned(instance_name); snapshot.name = Cow::Owned(instance_name);
snapshot.metadata.instigating_source = Some(entry.path().to_path_buf().into());
snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()]; snapshot.metadata.relevant_paths = vec![entry.path().to_path_buf()];
Ok(Some(snapshot)) Ok(Some(snapshot))

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo.client.lua
relevant_paths: relevant_paths:
- /foo.client.lua - /foo.client.lua
name: foo name: foo
@@ -13,4 +15,4 @@ properties:
Source: Source:
Type: String Type: String
Value: Hello there! Value: Hello there!
children: [] children: []

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo.csv
relevant_paths: relevant_paths:
- /foo.csv - /foo.csv
name: foo name: foo
@@ -13,4 +15,4 @@ properties:
Contents: Contents:
Type: String Type: String
Value: "[{\"key\":\"Ack\",\"example\":\"An exclamation of despair\",\"source\":\"Ack!\",\"values\":{\"es\":\"¡Ay!\"}}]" Value: "[{\"key\":\"Ack\",\"example\":\"An exclamation of despair\",\"source\":\"Ack!\",\"values\":{\"es\":\"¡Ay!\"}}]"
children: [] children: []

View File

@@ -5,9 +5,11 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo
relevant_paths: relevant_paths:
- /foo - /foo
name: foo name: foo
class_name: Folder class_name: Folder
properties: {} properties: {}
children: [] children: []

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo
relevant_paths: relevant_paths:
- /foo - /foo
name: foo name: foo
@@ -14,9 +16,11 @@ children:
- snapshot_id: ~ - snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo/Child
relevant_paths: relevant_paths:
- /foo/Child - /foo/Child
name: Child name: Child
class_name: Folder class_name: Folder
properties: {} properties: {}
children: [] children: []

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo.txt
relevant_paths: relevant_paths:
- /foo.txt - /foo.txt
name: foo name: foo
@@ -13,4 +15,4 @@ properties:
Value: Value:
Type: String Type: String
Value: Hello there! Value: Hello there!
children: [] children: []

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo.model.json
relevant_paths: relevant_paths:
- /foo.model.json - /foo.model.json
name: foo name: foo
@@ -21,4 +23,4 @@ children:
name: The Child name: The Child
class_name: StringValue class_name: StringValue
properties: {} properties: {}
children: [] children: []

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo.lua
relevant_paths: relevant_paths:
- /foo.lua - /foo.lua
name: foo name: foo
@@ -13,4 +15,4 @@ properties:
Source: Source:
Type: String Type: String
Value: Hello there! Value: Hello there!
children: [] children: []

View File

@@ -5,6 +5,8 @@ expression: instance_snapshot
snapshot_id: ~ snapshot_id: ~
metadata: metadata:
ignore_unknown_instances: false ignore_unknown_instances: false
instigating_source:
Path: /foo.server.lua
relevant_paths: relevant_paths:
- /foo.server.lua - /foo.server.lua
name: foo name: foo
@@ -13,4 +15,4 @@ properties:
Source: Source:
Type: String Type: String
Value: Hello there! Value: Hello there!
children: [] children: []

View File

@@ -52,6 +52,7 @@ impl SnapshotMiddleware for SnapshotTxt {
Ok(Some(InstanceSnapshot { Ok(Some(InstanceSnapshot {
snapshot_id: None, snapshot_id: None,
metadata: InstanceMetadata { metadata: InstanceMetadata {
instigating_source: Some(entry.path().to_path_buf().into()),
relevant_paths: vec![entry.path().to_path_buf()], relevant_paths: vec![entry.path().to_path_buf()],
..Default::default() ..Default::default()
}, },