diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2018-08-30 16:20:15 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2018-10-21 20:01:34 +0200 |
commit | 657f007cd294b9743d9a64e52c9ccdca8b3de3e1 (patch) | |
tree | 2dfd7b6e048e98a6188597e7d31e18e255aaf77e /src/io.c | |
parent | 39ab4665e6bb13372da24b86f32cc50fff8c0e9f (diff) | |
download | calcurse-657f007cd294b9743d9a64e52c9ccdca8b3de3e1.tar.gz calcurse-657f007cd294b9743d9a64e52c9ccdca8b3de3e1.zip |
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>
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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); } } |