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: https://github.com/getzola/zola/issues/2536
This commit is contained in:
parent
233e1cdcbd
commit
9774d761e3
|
@ -38,8 +38,7 @@ fn get_relevant_event_kind(event_kind: &EventKind) -> Option<SimpleFileSystemEve
|
|||
EventKind::Create(CreateKind::File) | EventKind::Create(CreateKind::Folder) => {
|
||||
Some(SimpleFileSystemEventKind::Create)
|
||||
}
|
||||
EventKind::Modify(ModifyKind::Data(DataChange::Size))
|
||||
| EventKind::Modify(ModifyKind::Data(DataChange::Content))
|
||||
EventKind::Modify(ModifyKind::Data(_))
|
||||
// Intellij modifies file metadata on edit.
|
||||
// https://github.com/passcod/notify/issues/150#issuecomment-494912080
|
||||
| EventKind::Modify(ModifyKind::Metadata(MetadataKind::WriteTime))
|
||||
|
@ -181,6 +180,14 @@ mod tests {
|
|||
EventKind::Modify(ModifyKind::Data(DataChange::Content)),
|
||||
Some(SimpleFileSystemEventKind::Modify),
|
||||
),
|
||||
(
|
||||
EventKind::Modify(ModifyKind::Data(DataChange::Any)),
|
||||
Some(SimpleFileSystemEventKind::Modify),
|
||||
),
|
||||
(
|
||||
EventKind::Modify(ModifyKind::Data(DataChange::Other)),
|
||||
Some(SimpleFileSystemEventKind::Modify),
|
||||
),
|
||||
(
|
||||
EventKind::Modify(ModifyKind::Metadata(MetadataKind::WriteTime)),
|
||||
Some(SimpleFileSystemEventKind::Modify),
|
||||
|
@ -202,7 +209,7 @@ mod tests {
|
|||
];
|
||||
for (case, expected) in cases.iter() {
|
||||
let ek = get_relevant_event_kind(&case);
|
||||
assert_eq!(ek, *expected);
|
||||
assert_eq!(ek, *expected, "case: {:?}", case);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue