summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-09-11 09:53:17 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-09-11 09:53:17 +0200
commit82372115ae4978abae3d91aa1149a002a3bb1540 (patch)
tree7c558edcca1540bfb5f8b69d662d8d4b9e81d6bb /src/core
parent71dfbdc41916b267d8f9b65799d0b85fec91f7de (diff)
downloadweechat-82372115ae4978abae3d91aa1149a002a3bb1540.zip
core: display a message when a configuration file is updated to a newer version
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-config-file.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 8cf646321..1e9b26bf8 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -3273,6 +3273,10 @@ config_file_parse_version (const char *version)
*
* Section can be updated only if option and value are NULL (ie if we are
* reading a section line like "[section]").
+ *
+ * Integer warning_update_displayed is set to 1 if a warning is displayed,
+ * when the file is updated to a newer version (then it's not compatible any
+ * more with previous versions).
*/
void
@@ -3282,7 +3286,8 @@ config_file_update_data_read (struct t_config_file *config_file,
const char *value,
char **ret_section,
char **ret_option,
- char **ret_value)
+ char **ret_value,
+ int *warning_update_displayed)
{
struct t_hashtable *data_read, *hashtable;
const char *ptr_section, *ptr_option, *ptr_value;
@@ -3292,6 +3297,21 @@ config_file_update_data_read (struct t_config_file *config_file,
if (config_file->version_read >= config_file->version)
return;
+ if (!*warning_update_displayed
+ && (config_file->version_read < config_file->version))
+ {
+ gui_chat_printf (
+ NULL,
+ _("%sImportant: file %s has been updated from version %d to %d, "
+ "it is not compatible and can not be loaded any more with any "
+ "older version"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ config_file->filename,
+ config_file->version_read,
+ config_file->version);
+ *warning_update_displayed = 1;
+ }
+
/* do nothing if there's no update callback */
if (!config_file->callback_update)
return;
@@ -3389,6 +3409,7 @@ int
config_file_read_internal (struct t_config_file *config_file, int reload)
{
int filename_length, line_number, rc, length, version;
+ int warning_update_displayed;
char *filename, *section, *option, *value;
struct t_config_section *ptr_section;
struct t_config_option *ptr_option;
@@ -3398,6 +3419,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
return WEECHAT_CONFIG_READ_FILE_NOT_FOUND;
config_file->version_read = 1;
+ warning_update_displayed = 0;
/* build filename */
filename_length = strlen (weechat_config_dir) + strlen (DIR_SEPARATOR) +
@@ -3498,7 +3520,8 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
{
config_file_update_data_read (config_file,
section, NULL, NULL,
- &section, NULL, NULL);
+ &section, NULL, NULL,
+ &warning_update_displayed);
ptr_section = config_file_search_section (config_file,
section);
if (!ptr_section)
@@ -3616,7 +3639,8 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
config_file_update_data_read (config_file,
ptr_section->name, option, value,
- NULL, &option, &value);
+ NULL, &option, &value,
+ &warning_update_displayed);
/* option has been ignored by the update callback? */
if (!option || !option[0])