From 657f007cd294b9743d9a64e52c9ccdca8b3de3e1 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Thu, 30 Aug 2018 16:20:15 +0200 Subject: 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 Signed-off-by: Lukas Fleischer --- src/io.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/io.c') diff --git a/src/io.c b/src/io.c index aa31313..16fddc3 100644 --- a/src/io.c +++ b/src/io.c @@ -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); } } -- cgit v1.2.3-54-g00ecf