A save refinement: no action if everything is unchanged

A reload action will do nothing if in-memory data as well as data files are
unchanged. This commit accomplishes the equivalent for a save action.

Because saving of configuration data and key bindings are mixed up with saving
of data files, any changes in those will only be saved if data files also have
changed. Hence, configuration data and key bindings are also saved upon exit
from the configuration menu.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2018-08-25 19:29:12 +02:00 committed by Lukas Fleischer
parent 5ad0019b23
commit d7777ed44e
2 changed files with 10 additions and 2 deletions

View File

@ -1154,4 +1154,8 @@ void custom_config_main(void)
wmove(win[STA].p, 0, 0);
wins_doupdate();
}
if (!config_save())
EXIT(_("Could not save %s."), path_conf);
if (!io_save_keys())
EXIT(_("Could not save %s."), path_keys);
}

View File

@ -586,8 +586,12 @@ int io_save_cal(enum save_display display)
if (read_only)
return IO_SAVE_CANCEL;
if (new_data() && (ret = resolve_save_conflict()))
return ret;
if (new_data()) {
if ((ret = resolve_save_conflict()))
return ret;
} else
if (!io_get_modified())
return IO_SAVE_CANCEL;
run_hook("pre-save");
io_mutex_lock();