[Commits] [SCM] claws branch, master, updated. 3.16.0-16-g5bcc8ea

ticho at claws-mail.org ticho at claws-mail.org
Fri Jan 19 18:57:07 CET 2018


The branch, master has been updated
       via  5bcc8ead3ddf78902cb940ba7659acf335f78247 (commit)
      from  9145ce96aff60a221244ca5245a594f72aaa8e89 (commit)

Summary of changes:
 src/folder.c          |   23 ++++++++++++++++++++++-
 src/prefs_migration.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 src/prefs_migration.h |    1 +
 3 files changed, 69 insertions(+), 1 deletion(-)


- Log -----------------------------------------------------------------
commit 5bcc8ead3ddf78902cb940ba7659acf335f78247
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Jan 19 18:56:52 2018 +0100

    Implement config_version in folderlist.xml.

diff --git a/src/folder.c b/src/folder.c
index 48a8d32..3f35f5e 100644
--- a/src/folder.c
+++ b/src/folder.c
@@ -61,9 +61,10 @@
 #include "main.h"
 #include "msgcache.h"
 #include "privacy.h"
+#include "prefs_common.h"
+#include "prefs_migration.h"
 
 /* Dependecies to be removed ?! */
-#include "prefs_common.h"
 #include "prefs_account.h"
 
 /* Define possible missing constants for Windows. */
@@ -830,6 +831,8 @@ gint folder_read_list(void)
 	GNode *node, *cur;
 	XMLNode *xmlnode;
 	gchar *path;
+	GList *list;
+	gint config_version = -1;
 
 	path = folder_get_list_path();
 	if (!is_file_exist(path)) return -1;
@@ -856,7 +859,23 @@ gint folder_read_list(void)
 		cur = cur->next;
 	}
 
+	for (list = xmlnode->tag->attr; list != NULL; list = list->next) {
+		XMLAttr *attr = list->data;
+
+		if (!attr || !attr->name || !attr->value) continue;
+		if (!strcmp(attr->name, "config_version")) {
+			config_version = atoi(attr->value);
+			debug_print("Found folderlist config_version %d\n", config_version);
+		}
+	}
+
 	xml_free_tree(node);
+
+	if (prefs_update_config_version_folderlist(config_version) < 0) {
+		debug_print("Folderlist configuration file version upgrade failed\n");
+		return -2;
+	}
+
 	if (folder_list || folder_unloaded_list)
 		return 0;
 	else
@@ -883,6 +902,8 @@ void folder_write_list(void)
 		return;		
 	}
 	tag = xml_tag_new("folderlist");
+	xml_tag_add_attr(tag, xml_attr_new_int("config_version",
+				CLAWS_CONFIG_VERSION));
 
 	xmlnode = xml_node_new(tag, NULL);
 
diff --git a/src/prefs_migration.c b/src/prefs_migration.c
index 251ba19..04f20a6 100644
--- a/src/prefs_migration.c
+++ b/src/prefs_migration.c
@@ -147,6 +147,22 @@ static void _update_config_password_store(gint version)
 	}
 }
 
+static void _update_config_folderlist(gint version)
+{
+	debug_print("Folderlist: Updating config version from %d to %d.\n",
+			version, version + 1);
+
+	switch (version) {
+		/* nothing here yet */
+
+		default:
+
+			/* NOOP */
+
+			break;
+	}
+}
+
 int prefs_update_config_version_common()
 {
 	gint ver = prefs_common_get_prefs()->config_version;
@@ -241,3 +257,33 @@ int prefs_update_config_version_password_store()
 	debug_print("Config update done.\n");
 	return 1;
 }
+
+int prefs_update_config_version_folderlist(gint from_version)
+{
+	gint ver = from_version;
+
+	if (ver == -1) {
+		/* There was no config_version stored in the config, let's assume
+		 * config_version same as clawsrc started at, to avoid breaking
+		 * the configuration by "upgrading" it unnecessarily. */
+		debug_print("Folderlist: config_version not saved, using one from clawsrc: %d\n", starting_config_version);
+		ver = starting_config_version;
+	}
+
+	debug_print("Starting config_update at config_version %d,\n", ver);
+
+	if (!_version_check(ver))
+		return -1;
+
+	if (ver == CLAWS_CONFIG_VERSION) {
+		debug_print("No update necessary, already at latest config_version.\n");
+		return 0; /* nothing to do */
+	}
+
+	while (ver < CLAWS_CONFIG_VERSION) {
+		_update_config_folderlist(ver++);
+	}
+
+	debug_print("Config update done.\n");
+	return 1;
+}
diff --git a/src/prefs_migration.h b/src/prefs_migration.h
index f1c5f15..05e2da6 100644
--- a/src/prefs_migration.h
+++ b/src/prefs_migration.h
@@ -22,5 +22,6 @@
 int prefs_update_config_version_common();
 int prefs_update_config_version_accounts();
 int prefs_update_config_version_password_store();
+int prefs_update_config_version_folderlist(gint from_version);
 
 #endif /* __PREFS_MIGRATION_H__ */

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list