From 52b802a11a0fafcb2dd84f3e06840d943aa8d933 Mon Sep 17 00:00:00 2001 From: 8roken <211849604+8roken@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:44:20 -0400 Subject: [PATCH] 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. --- cosmic-config/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cosmic-config/src/lib.rs b/cosmic-config/src/lib.rs index 7a392fde..1a3ec66a 100644 --- a/cosmic-config/src/lib.rs +++ b/cosmic-config/src/lib.rs @@ -1,7 +1,7 @@ //! Integrations for cosmic-config — the cosmic configuration system. use notify::{ - event::{EventKind, ModifyKind}, + event::{EventKind, ModifyKind, RenameMode}, RecommendedWatcher, Watcher, }; use serde::{de::DeserializeOwned, Serialize}; @@ -261,7 +261,9 @@ impl Config { match event_res { Ok(event) => { match &event.kind { - EventKind::Access(_) | EventKind::Modify(ModifyKind::Metadata(_)) => { + EventKind::Access(_) + | EventKind::Modify(ModifyKind::Metadata(_)) + | EventKind::Modify(ModifyKind::Name(RenameMode::Both)) => { // Data not mutated return; }