diff options
author | Thomas Haller <thaller@redhat.com> | 2015-01-13 14:09:23 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-01-13 16:41:30 +0100 |
commit | 8ba8a55cfa7169d0ca7e03decbfe99983ad04c32 (patch) | |
tree | 03cbed0bdee532759269b605a5a5a051146f9d26 | |
parent | db5c4ce64ffd32b339dd59aae6394396d800d4f3 (diff) | |
download | NetworkManager-8ba8a55cfa7169d0ca7e03decbfe99983ad04c32.tar.gz |
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().
-rw-r--r-- | src/settings/plugins/keyfile/plugin.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index 2a5820226e..872de4bb8a 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -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; |