about summary refs log tree commit diff
path: root/src/settings/plugins/keyfile/nm-keyfile-connection.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2014-07-06 03:04:17 +0200
committerMichael Biebl <biebl@debian.org>2014-07-06 03:04:17 +0200
commit3ce667b6ee6b86291bbe60ef93cba7f11a5c5400 (patch)
treeaf3daa7221e898b72f3de26eb2cf0c1b1c8661b0 /src/settings/plugins/keyfile/nm-keyfile-connection.c
parentf02d31d95af29678092d1ff01f714621bc9dcc0f (diff)
parent33491bc4279481db8ae47213e34a6d695a0e8830 (diff)
Merge tag 'upstream/0.9.10.0'
Upstream version 0.9.10.0
Diffstat (limited to 'src/settings/plugins/keyfile/nm-keyfile-connection.c')
-rw-r--r--src/settings/plugins/keyfile/nm-keyfile-connection.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/settings/plugins/keyfile/nm-keyfile-connection.c b/src/settings/plugins/keyfile/nm-keyfile-connection.c
index 6d72bbfe..4ef761c6 100644
--- a/src/settings/plugins/keyfile/nm-keyfile-connection.c
+++ b/src/settings/plugins/keyfile/nm-keyfile-connection.c
@@ -41,16 +41,17 @@ typedef struct {
 } NMKeyfileConnectionPrivate;
 
 NMKeyfileConnection *
-nm_keyfile_connection_new (const char *full_path,
-                           NMConnection *source,
+nm_keyfile_connection_new (NMConnection *source,
+                           const char *full_path,
                            GError **error)
 {
 	GObject *object;
 	NMKeyfileConnectionPrivate *priv;
 	NMConnection *tmp;
 	const char *uuid;
+	gboolean update_unsaved = TRUE;
 
-	g_return_val_if_fail (full_path != NULL, NULL);
+	g_assert (source || full_path);
 
 	/* If we're given a connection already, prefer that instead of re-reading */
 	if (source)
@@ -59,31 +60,33 @@ nm_keyfile_connection_new (const char *full_path,
 		tmp = nm_keyfile_plugin_connection_from_file (full_path, error);
 		if (!tmp)
 			return NULL;
+
+		uuid = nm_connection_get_uuid (NM_CONNECTION (tmp));
+		if (!uuid) {
+			g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
+			             "Connection in file %s had no UUID", full_path);
+			g_object_unref (tmp);
+			return NULL;
+		}
+
+		/* If we just read the connection from disk, it's clearly not Unsaved */
+		update_unsaved = FALSE;
 	}
 
 	object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION, NULL);
-	if (!object)
-		goto out;
 
 	priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (object);
 	priv->path = g_strdup (full_path);
 
 	/* Update our settings with what was read from the file */
-	if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object), tmp, error)) {
-		g_object_unref (object);
-		object = NULL;
-		goto out;
-	}
-
-	uuid = nm_connection_get_uuid (NM_CONNECTION (object));
-	if (!uuid) {
-		g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
-		             "Connection in file %s had no UUID", full_path);
+	if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
+	                                              tmp,
+	                                              update_unsaved,
+	                                              error)) {
 		g_object_unref (object);
 		object = NULL;
 	}
 
-out:
 	g_object_unref (tmp);
 	return (NMKeyfileConnection *) object;
 }
@@ -145,7 +148,8 @@ do_delete (NMSettingsConnection *connection,
 {
 	NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
 
-	g_unlink (priv->path);
+	if (priv->path)
+		g_unlink (priv->path);
 
 	NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection,
 	                                                                           callback,