diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c index 23618f7c2b..6d72bbfe51 100644 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. */ #include @@ -96,6 +96,19 @@ nm_keyfile_connection_get_path (NMKeyfileConnection *self) return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->path; } +void +nm_keyfile_connection_set_path (NMKeyfileConnection *self, const char *path) +{ + NMKeyfileConnectionPrivate *priv; + + g_return_if_fail (NM_IS_KEYFILE_CONNECTION (self)); + g_return_if_fail (path != NULL); + + priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (self); + g_free (priv->path); + priv->path = g_strdup (path); +} + static void commit_changes (NMSettingsConnection *connection, NMSettingsConnectionCommitFunc callback, diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.h b/src/settings/plugins/keyfile/nm-keyfile-connection.h index 932b36f7c2..e3bce11b5f 100644 --- a/src/settings/plugins/keyfile/nm-keyfile-connection.h +++ b/src/settings/plugins/keyfile/nm-keyfile-connection.h @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. */ #ifndef NM_KEYFILE_CONNECTION_H @@ -48,6 +48,7 @@ NMKeyfileConnection *nm_keyfile_connection_new (const char *filename, GError **error); const char *nm_keyfile_connection_get_path (NMKeyfileConnection *self); +void nm_keyfile_connection_set_path (NMKeyfileConnection *self, const char *path); G_END_DECLS diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c index d53907a9f7..062eb0822f 100644 --- a/src/settings/plugins/keyfile/plugin.c +++ b/src/settings/plugins/keyfile/plugin.c @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. */ #include @@ -268,6 +268,10 @@ dir_changed (GFileMonitor *monitor, * filename property too. */ update_connection_settings (found, connection); + /* However, when connections are the same and only the filename changed + * we need to update the path manually (commit_changes() is not called. + */ + nm_keyfile_connection_set_path (found, full_path); /* Re-insert the connection back into the hash with the new filename */ g_hash_table_insert (priv->hash, diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c index 2a5ce2bdff..81d11ce3b8 100644 --- a/src/settings/plugins/keyfile/writer.c +++ b/src/settings/plugins/keyfile/writer.c @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Copyright (C) 2008 Novell, Inc. - * Copyright (C) 2008 - 2011 Red Hat, Inc. + * Copyright (C) 2008 - 2012 Red Hat, Inc. */ #include @@ -1026,8 +1026,15 @@ _internal_write_connection (NMConnection *connection, if (!data) goto out; - filename = _writer_id_to_filename (id); - path = g_build_filename (keyfile_dir, filename, NULL); + /* If we have existing file path, use it. Else generate one from + * connection's ID. + */ + if (existing_path != NULL) { + path = g_strdup (existing_path); + } else { + filename = _writer_id_to_filename (id); + path = g_build_filename (keyfile_dir, filename, NULL); + } /* If a file with this path already exists (but isn't the existing path * of the connection) then we need another name. Multiple connections