ifcfg-rh: don't shortcut writing if the connection stays the same

Some keys, such as MASTER may still be different as they may depend on
other connections. svWriteFile() checks if the resulting file is
different already anyway.
This commit is contained in:
Lubomir Rintel 2017-02-21 10:14:50 +01:00
parent 61722fdeb1
commit 54086127ef

View file

@ -336,35 +336,12 @@ commit_changes (NMSettingsConnection *connection,
gpointer user_data)
{
GError *error = NULL;
NMConnection *reread;
gboolean same = FALSE, success = FALSE;
gboolean success = FALSE;
char *ifcfg_path = NULL;
const char *filename;
/* To ensure we don't rewrite files that are only changed from other
* processes on-disk, read the existing connection back in and only rewrite
* it if it's really changed.
*/
filename = nm_settings_connection_get_filename (connection);
if (filename) {
gs_free char *unhandled = NULL;
reread = connection_from_file (filename, &unhandled, NULL, NULL);
if (reread) {
same = nm_connection_compare (NM_CONNECTION (connection),
reread,
NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS);
g_object_unref (reread);
/* Don't bother writing anything out if in-memory and on-disk data are the same */
if (same) {
/* But chain up to parent to handle success - emits updated signal */
NM_SETTINGS_CONNECTION_CLASS (nm_ifcfg_connection_parent_class)->commit_changes (connection, commit_reason, callback, user_data);
return;
}
}
success = writer_update_connection (NM_CONNECTION (connection),
IFCFG_DIR,
filename,