[evolution/eds-mailer: 3/49] Automatically migrate filter definition file on upgrade
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution/eds-mailer: 3/49] Automatically migrate filter definition file on upgrade
- Date: Wed, 13 Jan 2010 15:48:17 +0000 (UTC)
commit e5062544016aaac0b3ed697b138943f57b28f23f
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Mon Dec 21 15:50:12 2009 -0600
Automatically migrate filter definition file on upgrade
Because the backend will need to have more information stored in the filters.xml
file now (it's reading the cached s-expression rather than re-building it), we
migrate the filters file at startup so that it will contain the extra data.
mail/e-mail-migrate.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c
index f67ea38..3e3a064 100644
--- a/mail/e-mail-migrate.c
+++ b/mail/e-mail-migrate.c
@@ -67,8 +67,9 @@
#include "shell/e-shell-migrate.h"
#include "e-mail-store.h"
-#include "mail-config.h"
+#include "em-filter-context.h"
#include "em-utils.h"
+#include "mail-config.h"
#define d(x) x
@@ -2989,6 +2990,27 @@ migrate_to_db (EShellBackend *shell_backend)
g_object_unref (session);
}
+/* Load the email filters and re-save them since there was some new cached
+ * information added to the filter file format */
+static void
+migrate_email_filters_2_29 (EShellBackend *shell_backend)
+{
+ ERuleContext *fc;
+ gchar *user, *system;
+ const gchar *data_dir = e_shell_backend_get_data_dir (shell_backend);
+
+ user = g_build_filename (data_dir, "filters.xml", NULL);
+ system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL);
+
+ fc = (ERuleContext *) em_filter_context_new ();
+ e_rule_context_load (fc, system, user);
+ if (e_rule_context_save (fc, user) == -1)
+ g_warning ("Couldn't migrate filter rules '%s'", user);
+
+ g_free (system);
+ g_free (user);
+}
+
gboolean
e_mail_migrate (EShellBackend *shell_backend,
gint major,
@@ -3093,5 +3115,9 @@ e_mail_migrate (EShellBackend *shell_backend,
migrate_to_db (shell_backend);
}
+ if (major < 2 || (major == 2 && minor < 30)) {
+ migrate_email_filters_2_29 (shell_backend);
+ }
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]