fix(cosmic-config): Avoid dual notifications in transaction commits
When a transaction gets committed, the files gets written to a file in the .atomicwrite[0-9a-Z] folder and then gets moved to their final location. The watcher will emit two events: - Modify(Name(To)) - Modify(Name(Both) The last one will include both the source and the destination and is essentially a duplicate of the first event. By discarding this event, behavior seems to be the same, and all consumers of those events get only notified once instead of twice when a configuration changes.
This commit is contained in:
parent
dfdca0ef81
commit
52b802a11a
1 changed files with 4 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
//! Integrations for cosmic-config — the cosmic configuration system.
|
//! Integrations for cosmic-config — the cosmic configuration system.
|
||||||
|
|
||||||
use notify::{
|
use notify::{
|
||||||
event::{EventKind, ModifyKind},
|
event::{EventKind, ModifyKind, RenameMode},
|
||||||
RecommendedWatcher, Watcher,
|
RecommendedWatcher, Watcher,
|
||||||
};
|
};
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
|
|
@ -261,7 +261,9 @@ impl Config {
|
||||||
match event_res {
|
match event_res {
|
||||||
Ok(event) => {
|
Ok(event) => {
|
||||||
match &event.kind {
|
match &event.kind {
|
||||||
EventKind::Access(_) | EventKind::Modify(ModifyKind::Metadata(_)) => {
|
EventKind::Access(_)
|
||||||
|
| EventKind::Modify(ModifyKind::Metadata(_))
|
||||||
|
| EventKind::Modify(ModifyKind::Name(RenameMode::Both)) => {
|
||||||
// Data not mutated
|
// Data not mutated
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue