diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 33cbd67112..8d22c8bc11 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -495,9 +495,6 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe | NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED | NM_SETTINGS_CONNECTION_FLAGS_VOLATILE; - if (persist_mode == NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP) - return; - switch (persist_mode) { case NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK: flags = NM_SETTINGS_CONNECTION_FLAGS_NONE; @@ -512,8 +509,16 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe flags = NM_SETTINGS_CONNECTION_FLAGS_UNSAVED | NM_SETTINGS_CONNECTION_FLAGS_VOLATILE; break; + case NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED: + /* only set the connection as unsaved, but preserve the nm-generated + * and volatile flag. */ + nm_settings_connection_set_flags (self, + NM_SETTINGS_CONNECTION_FLAGS_UNSAVED, + TRUE); + return; case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP: - g_return_if_reached (); + /* Nothing to do */ + return; } nm_settings_connection_set_flags_full (self, ALL, flags); @@ -522,7 +527,7 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe static void connection_changed_cb (NMSettingsConnection *self, gpointer unused) { - set_persist_mode (self, NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY); + set_persist_mode (self, NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED); _emit_updated (self, FALSE); } diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h index 051fcf7ff9..fc8ad1de1a 100644 --- a/src/settings/nm-settings-connection.h +++ b/src/settings/nm-settings-connection.h @@ -138,6 +138,11 @@ gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsCon typedef enum { NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP, NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK, + + /* unsaved, only sets the unsaved flag, but it doesn't touch + * the NM_GENERATED nor VOLATILE flag. */ + NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED, + NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY, NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_DETACHED, NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_ONLY, diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c index b81a9eb919..3cf5c978c9 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c @@ -443,7 +443,7 @@ nm_ifcfg_connection_new (NMConnection *source, tmp, full_path ? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP /* connection is already on disk */ - : NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY, + : NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, error)) diff --git a/src/settings/plugins/ifnet/nms-ifnet-connection.c b/src/settings/plugins/ifnet/nms-ifnet-connection.c index aeb4467472..e7cd19cd2c 100644 --- a/src/settings/plugins/ifnet/nms-ifnet-connection.c +++ b/src/settings/plugins/ifnet/nms-ifnet-connection.c @@ -189,7 +189,7 @@ nm_ifnet_connection_new (NMConnection *source, const char *conn_name) if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object), tmp, update_unsaved - ? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY + ? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED : NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL, diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.c b/src/settings/plugins/keyfile/nms-keyfile-connection.c index 9e9ab9621b..5a6d8a76e7 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nms-keyfile-connection.c @@ -162,7 +162,7 @@ nms_keyfile_connection_new (NMConnection *source, if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object), tmp, update_unsaved - ? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY + ? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED : NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE, NULL,