Skip to content

Commit 9774d76

Browse files
lukehsiaoKeats
authored andcommitted
fix: treat any data change as a modification (#2542)
For unknown reasons, it seems some environments emit a `DataChange::Any` event, rather than specifying content or size, when a file is edited. As an example: [src/fs_utils.rs:72:9] &event = DebouncedEvent { event: Event { kind: Modify( Data( Any, ), ), paths: [ "/home/redacted/content/blog/2024-06-23_example.md", ], attr:tracker: None, attr:flag: None, attr:info: None, attr:source: None, }, time: Instant { tv_sec: 78544, tv_nsec: 936740729, }, } Consequently, because this isn't treated by Zola as a modification, the site is not rebuilt, which regresses on previous behavior. This patch fixes this particular case by treating any data modification events as a modification. Closes: #2536
1 parent 233e1cd commit 9774d76

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/fs_utils.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ fn get_relevant_event_kind(event_kind: &EventKind) -> Option<SimpleFileSystemEve
3838
EventKind::Create(CreateKind::File) | EventKind::Create(CreateKind::Folder) => {
3939
Some(SimpleFileSystemEventKind::Create)
4040
}
41-
EventKind::Modify(ModifyKind::Data(DataChange::Size))
42-
| EventKind::Modify(ModifyKind::Data(DataChange::Content))
41+
EventKind::Modify(ModifyKind::Data(_))
4342
// Intellij modifies file metadata on edit.
4443
// https://github.com/passcod/notify/issues/150#issuecomment-494912080
4544
| EventKind::Modify(ModifyKind::Metadata(MetadataKind::WriteTime))
@@ -181,6 +180,14 @@ mod tests {
181180
EventKind::Modify(ModifyKind::Data(DataChange::Content)),
182181
Some(SimpleFileSystemEventKind::Modify),
183182
),
183+
(
184+
EventKind::Modify(ModifyKind::Data(DataChange::Any)),
185+
Some(SimpleFileSystemEventKind::Modify),
186+
),
187+
(
188+
EventKind::Modify(ModifyKind::Data(DataChange::Other)),
189+
Some(SimpleFileSystemEventKind::Modify),
190+
),
184191
(
185192
EventKind::Modify(ModifyKind::Metadata(MetadataKind::WriteTime)),
186193
Some(SimpleFileSystemEventKind::Modify),
@@ -202,7 +209,7 @@ mod tests {
202209
];
203210
for (case, expected) in cases.iter() {
204211
let ek = get_relevant_event_kind(&case);
205-
assert_eq!(ek, *expected);
212+
assert_eq!(ek, *expected, "case: {:?}", case);
206213
}
207214
}
208215

0 commit comments

Comments
 (0)