Distinguish between interactive and periodic save

A new argument to io_save_cal() makes it possible for the periodic save thread
to avoid 1) user interaction and 2) overwriting new data.

At the moment the thread has no way to report on the result of the save.

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-30 16:20:15 +02:00
committed by Lukas Fleischer
parent 39ab4665e6
commit 657f007cd2
3 changed files with 17 additions and 9 deletions

View File

@@ -490,16 +490,20 @@ cleanup:
* IO_SAVE_NOOP: cancel save operation (nothing has changed)
* IO_SAVE_ERROR: cannot access data
*/
int io_save_cal(void)
int io_save_cal(enum save_type s_t)
{
int ret;
if (read_only)
return IO_SAVE_CANCEL;
if ((ret = new_data()) == NOKNOW) {
if ((ret = new_data()) == NOKNOW)
return IO_SAVE_ERROR;
} else if (ret) { /* New data */
if (ret) { /* New data */
if (s_t == periodic)
return IO_SAVE_CANCEL;
/* Interactively decide what to do. */
if ((ret = resolve_save_conflict()))
return ret;
} else /* No new data */
@@ -1422,7 +1426,7 @@ static void *io_psave_thread(void *arg)
for (;;) {
sleep(delay * MININSEC);
io_save_cal();
io_save_cal(periodic);
}
}