aboutsummaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2017-09-08 07:44:35 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2017-09-08 21:08:54 +0200
commit57dd3d6b66156936d170893765d45a169e7010af (patch)
tree934958fe226dfb8655884a6d0aca739809c53ba4 /src/io.c
parentba85d9b6f5e9854c7d4ec47e2a91b53e7f454f21 (diff)
downloadcalcurse-57dd3d6b66156936d170893765d45a169e7010af.tar.gz
calcurse-57dd3d6b66156936d170893765d45a169e7010af.zip
Only reload if data files were changed
Instead of blindly reloading data in io_reload_data(), compare the stored hashes of the data files with hashes of the current file contents and only reload if any of the hashes differs. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index 9e75262..0cefa9c 100644
--- a/src/io.c
+++ b/src/io.c
@@ -870,12 +870,13 @@ void io_load_data(struct item_filter *filter)
run_hook("post-load");
}
-void io_reload_data(void)
+int io_reload_data(void)
{
char *msg_um_asktype = NULL;
const char *reload_success =
_("The data files were reloaded successfully");
const char *enter = _("Press [ENTER] to continue");
+ int ret = 0;
if (io_get_modified()) {
const char *msg_um_prefix =
@@ -902,6 +903,9 @@ void io_reload_data(void)
}
}
+ if (!io_check_data_files_modified())
+ goto cleanup;
+
if (notify_bar())
notify_stop_main_thread();
@@ -939,8 +943,11 @@ void io_reload_data(void)
if (notify_bar())
notify_start_main_thread();
+ ret = 1;
+
cleanup:
mem_free(msg_um_asktype);
+ return ret;
}
static void