mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 00:00:08 +01:00
keyfile: ignore GFileMonitor change flags in dir_changed()
When writing a file (for example with `sed -i`) a temporary file
might be created and removed quickly. This causes spurious events
in dir_changed().
(cherry picked from commit 8ba8a55cfa)
This commit is contained in:
parent
8c97626918
commit
6cd264b0d5
1 changed files with 6 additions and 3 deletions
|
|
@ -290,25 +290,28 @@ dir_changed (GFileMonitor *monitor,
|
|||
SCPluginKeyfile *self = SC_PLUGIN_KEYFILE (config);
|
||||
NMKeyfileConnection *connection;
|
||||
char *full_path;
|
||||
gboolean exists;
|
||||
|
||||
full_path = g_file_get_path (file);
|
||||
if (nm_keyfile_plugin_utils_should_ignore_file (full_path)) {
|
||||
g_free (full_path);
|
||||
return;
|
||||
}
|
||||
exists = g_file_test (full_path, G_FILE_TEST_EXISTS);
|
||||
|
||||
nm_log_dbg (LOGD_SETTINGS, "dir_changed(%s) = %d", full_path, event_type);
|
||||
nm_log_dbg (LOGD_SETTINGS, "dir_changed(%s) = %d; file %s", full_path, event_type, exists ? "exists" : "does not exist");
|
||||
|
||||
connection = find_by_path (self, full_path);
|
||||
|
||||
switch (event_type) {
|
||||
case G_FILE_MONITOR_EVENT_DELETED:
|
||||
if (connection)
|
||||
if (!exists && connection)
|
||||
remove_connection (SC_PLUGIN_KEYFILE (config), connection);
|
||||
break;
|
||||
case G_FILE_MONITOR_EVENT_CREATED:
|
||||
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
|
||||
update_connection (SC_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL);
|
||||
if (exists)
|
||||
update_connection (SC_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue