[Commits] [SCM] claws branch, master, updated. 3.17.0-144-gc44e3b3

ticho at claws-mail.org ticho at claws-mail.org
Mon Nov 5 20:30:40 CET 2018


The branch, master has been updated
       via  c44e3b37b257a03e2563dd1aea75d29e00c66747 (commit)
      from  bae51cedfb4b63ae249230cb8fc1d497ff89a4ca (commit)

Summary of changes:
 src/folder_item_prefs.c |    5 +++
 src/folder_item_prefs.h |    2 ++
 src/prefs_migration.c   |   80 +++++++++++++++++++++++++++++++++++++++++------
 src/prefs_migration.h   |    1 +
 4 files changed, 79 insertions(+), 9 deletions(-)


- Log -----------------------------------------------------------------
commit c44e3b37b257a03e2563dd1aea75d29e00c66747
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Nov 5 11:49:21 2018 +0100

    Add config_version to folder item prefs.
    
    Also some minor code comment and debug output tweaks.

diff --git a/src/folder_item_prefs.c b/src/folder_item_prefs.c
index 874f18d..14137d5 100644
--- a/src/folder_item_prefs.c
+++ b/src/folder_item_prefs.c
@@ -31,6 +31,7 @@
 #include "prefs_gtk.h"
 #include "filtering.h"
 #include "folder_item_prefs.h"
+#include "prefs_migration.h"
 
 FolderItemPrefs tmp_prefs;
 
@@ -124,6 +125,8 @@ static PrefParam param[] = {
 	 NULL, NULL, NULL},
 	{"forward_body_format", NULL, &tmp_prefs.forward_body_format, P_STRING,
 	 NULL, NULL, NULL},
+	{"config_version", "-1", &tmp_prefs.config_version, P_INT,
+	 NULL, NULL, NULL},
 	{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
 
@@ -142,6 +145,8 @@ void folder_item_prefs_read_config(FolderItem * item)
 	g_free(rcpath);
 
 	*item->prefs = tmp_prefs;
+
+	prefs_update_config_version_folder_item(item);
 }
 
 void folder_item_prefs_save_config(FolderItem * item)
diff --git a/src/folder_item_prefs.h b/src/folder_item_prefs.h
index aa649c4..621dbef 100644
--- a/src/folder_item_prefs.h
+++ b/src/folder_item_prefs.h
@@ -40,6 +40,8 @@ typedef enum {
 struct _FolderItemPrefs {
 	gchar * directory;
 
+	gint config_version;
+
 	int enable_processing; /* at start-up */
 	int enable_processing_when_opening;
 	GSList * processing;
diff --git a/src/prefs_migration.c b/src/prefs_migration.c
index 287d9e8..a508392 100644
--- a/src/prefs_migration.c
+++ b/src/prefs_migration.c
@@ -30,6 +30,7 @@
 
 #include "defs.h"
 #include "account.h"
+#include "folder_item_prefs.h"
 #include "prefs_account.h"
 #include "prefs_common.h"
 #include "alertpanel.h"
@@ -184,6 +185,23 @@ static void _update_config_folderlist(gint version)
 	}
 }
 
+static void _update_config_folder_item(FolderItem *item,
+		gint version)
+{
+	debug_print("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;
@@ -219,9 +237,10 @@ int prefs_update_config_version_accounts()
 		ac_prefs = (PrefsAccount *)cur->data;
 
 		if (ac_prefs->config_version == -1) {
-			/* There was no config_version stored in accountrc, let's assume
-			 * config_version same as clawsrc started at, to avoid breaking
-			 * this account by "upgrading" it unnecessarily. */
+			/* There was no config_version stored in the config, let's
+			 * assume config_version same as what clawsrc started at
+			 * this session, to avoid breaking the configuration by
+			 * "upgrading" it unnecessarily. */
 			debug_print("Account '%s': config_version not saved, using one from clawsrc: %d\n", ac_prefs->account_name, starting_config_version);
 			ac_prefs->config_version = starting_config_version;
 		}
@@ -243,6 +262,7 @@ int prefs_update_config_version_accounts()
 		}
 	}
 
+	debug_print("Accounts config update done.\n");
 	return 1;
 }
 
@@ -252,8 +272,8 @@ int prefs_update_config_version_password_store(gint 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. */
+		 * config_version same as what clawsrc started at this session,
+		 * to avoid breaking the configuration by "upgrading" it unnecessarily. */
 		debug_print("Password store: config_version not saved, using one from clawsrc: %d\n", starting_config_version);
 		ver = starting_config_version;
 	}
@@ -272,7 +292,7 @@ int prefs_update_config_version_password_store(gint from_version)
 		_update_config_password_store(ver++);
 	}
 
-	debug_print("Config update done.\n");
+	debug_print("Passwordstore config update done.\n");
 	return 1;
 }
 
@@ -282,8 +302,8 @@ int prefs_update_config_version_folderlist(gint 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. */
+		 * config_version same as what clawsrc started at this session,
+		 * 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;
 	}
@@ -302,6 +322,48 @@ int prefs_update_config_version_folderlist(gint from_version)
 		_update_config_folderlist(ver++);
 	}
 
-	debug_print("Config update done.\n");
+	debug_print("Folderlist config update done.\n");
 	return 1;
 }
+
+int prefs_update_config_version_folder_item(FolderItem *item)
+{
+	gint ver;
+	gchar *id;
+
+	cm_return_val_if_fail(item != NULL, 0);
+
+	id = folder_item_get_identifier(item);
+
+	if (item->prefs->config_version == -1) {
+		/* There was no config_version stored in the config, let's assume
+		 * config_version same as what clawsrc started at this session,
+		 * to avoid breaking the configuration by "upgrading" it unnecessarily. */
+		debug_print("Folder item '%s': config_version not saved, using one from clawsrc: %d\n", id, starting_config_version);
+		item->prefs->config_version = starting_config_version;
+	}
+
+	ver = item->prefs->config_version;
+
+	if (!_version_check(ver)) {
+		g_free(id);
+		return -1;
+	}
+
+	if (ver == CLAWS_CONFIG_VERSION) {
+		debug_print("Folder item '%s': No update necessary, already at latest config_version %d.\n", id, ver);
+		g_free(id);
+		return 0; /* nothing to do */
+	}
+
+	debug_print("Folder item '%s': starting config_update at version %d.\n",
+			id, ver);
+	g_free(id);
+
+	while (ver < CLAWS_CONFIG_VERSION) {
+		_update_config_folder_item(item, ver++);
+	}
+
+	debug_print("Folder item config update done.\n");
+	return 0;
+}
diff --git a/src/prefs_migration.h b/src/prefs_migration.h
index 047c7c0..0adf38c 100644
--- a/src/prefs_migration.h
+++ b/src/prefs_migration.h
@@ -23,5 +23,6 @@ int prefs_update_config_version_common();
 int prefs_update_config_version_accounts();
 int prefs_update_config_version_password_store(gint from_version);
 int prefs_update_config_version_folderlist(gint from_version);
+int prefs_update_config_version_folder_item(FolderItem *item);
 
 #endif /* __PREFS_MIGRATION_H__ */

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list