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 authored and Lukas Fleischer committed 2018-10-21 20:01:34 +02:00
1 parent 5ad0019b23
commit d7777ed44e
2 files changed
+10 -2

No files matched your search

+4
View File
@@ -1154,4 +1154,8 @@ void custom_config_main(void)
wmove(win[STA].p, 0, 0); wmove(win[STA].p, 0, 0);
wins_doupdate(); wins_doupdate();
} }
if (!config_save())
EXIT(_("Could not save %s."), path_conf);
if (!io_save_keys())
EXIT(_("Could not save %s."), path_keys);
} }
+6 -2
View File
@@ -586,8 +586,12 @@ int io_save_cal(enum save_display display)
if (read_only) if (read_only)
return IO_SAVE_CANCEL; return IO_SAVE_CANCEL;
if (new_data() && (ret = resolve_save_conflict())) if (new_data()) {
return ret; if ((ret = resolve_save_conflict()))
return ret;
} else
if (!io_get_modified())
return IO_SAVE_CANCEL;
run_hook("pre-save"); run_hook("pre-save");
io_mutex_lock(); io_mutex_lock();