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>
This commit is contained in:
parent
ba85d9b6f5
commit
57dd3d6b66
@ -277,11 +277,12 @@ static inline void key_generic_save(void)
|
|||||||
|
|
||||||
static inline void key_generic_reload(void)
|
static inline void key_generic_reload(void)
|
||||||
{
|
{
|
||||||
io_reload_data();
|
if (io_reload_data()) {
|
||||||
do_storage(0);
|
do_storage(0);
|
||||||
notify_check_next_app(1);
|
notify_check_next_app(1);
|
||||||
ui_calendar_monthly_view_cache_set_invalid();
|
ui_calendar_monthly_view_cache_set_invalid();
|
||||||
wins_update(FLAG_ALL);
|
wins_update(FLAG_ALL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void key_generic_import(void)
|
static inline void key_generic_import(void)
|
||||||
|
@ -847,7 +847,7 @@ void io_save_cal(enum save_display);
|
|||||||
void io_load_app(struct item_filter *);
|
void io_load_app(struct item_filter *);
|
||||||
void io_load_todo(struct item_filter *);
|
void io_load_todo(struct item_filter *);
|
||||||
void io_load_data(struct item_filter *);
|
void io_load_data(struct item_filter *);
|
||||||
void io_reload_data(void);
|
int io_reload_data(void);
|
||||||
void io_load_keys(const char *);
|
void io_load_keys(const char *);
|
||||||
int io_check_dir(const char *);
|
int io_check_dir(const char *);
|
||||||
unsigned io_dir_exists(const char *);
|
unsigned io_dir_exists(const char *);
|
||||||
|
9
src/io.c
9
src/io.c
@ -870,12 +870,13 @@ void io_load_data(struct item_filter *filter)
|
|||||||
run_hook("post-load");
|
run_hook("post-load");
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_reload_data(void)
|
int io_reload_data(void)
|
||||||
{
|
{
|
||||||
char *msg_um_asktype = NULL;
|
char *msg_um_asktype = NULL;
|
||||||
const char *reload_success =
|
const char *reload_success =
|
||||||
_("The data files were reloaded successfully");
|
_("The data files were reloaded successfully");
|
||||||
const char *enter = _("Press [ENTER] to continue");
|
const char *enter = _("Press [ENTER] to continue");
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (io_get_modified()) {
|
if (io_get_modified()) {
|
||||||
const char *msg_um_prefix =
|
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())
|
if (notify_bar())
|
||||||
notify_stop_main_thread();
|
notify_stop_main_thread();
|
||||||
|
|
||||||
@ -939,8 +943,11 @@ void io_reload_data(void)
|
|||||||
if (notify_bar())
|
if (notify_bar())
|
||||||
notify_start_main_thread();
|
notify_start_main_thread();
|
||||||
|
|
||||||
|
ret = 1;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mem_free(msg_um_asktype);
|
mem_free(msg_um_asktype);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user