mirror of
https://github.com/typst/typst
synced 2025-08-12 22:27:56 +08:00
Fix high CPU usage due to inotify watch triggering itself
This commit is contained in:
parent
d199546f9f
commit
45c6a1d972
@ -237,16 +237,7 @@ impl Watcher {
|
|||||||
|
|
||||||
/// Whether a watch event is relevant for compilation.
|
/// Whether a watch event is relevant for compilation.
|
||||||
fn is_event_relevant(&self, event: ¬ify::Event) -> bool {
|
fn is_event_relevant(&self, event: ¬ify::Event) -> bool {
|
||||||
// Never recompile because the output file changed.
|
let type_relevant = match &event.kind {
|
||||||
if event
|
|
||||||
.paths
|
|
||||||
.iter()
|
|
||||||
.all(|path| is_same_file(path, &self.output).unwrap_or(false))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
match &event.kind {
|
|
||||||
notify::EventKind::Any => true,
|
notify::EventKind::Any => true,
|
||||||
notify::EventKind::Access(_) => false,
|
notify::EventKind::Access(_) => false,
|
||||||
notify::EventKind::Create(_) => true,
|
notify::EventKind::Create(_) => true,
|
||||||
@ -259,7 +250,14 @@ impl Watcher {
|
|||||||
},
|
},
|
||||||
notify::EventKind::Remove(_) => true,
|
notify::EventKind::Remove(_) => true,
|
||||||
notify::EventKind::Other => false,
|
notify::EventKind::Other => false,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Never recompile because the output file changed.
|
||||||
|
return type_relevant
|
||||||
|
&& !event
|
||||||
|
.paths
|
||||||
|
.iter()
|
||||||
|
.all(|path| is_same_file(path, &self.output).unwrap_or(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user