[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-keywords.c, 1.6, 1.6.2.1 maildir-storage.c, 1.115.2.6, 1.115.2.7

cras at dovecot.org cras at dovecot.org
Tue Jul 4 20:03:30 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv1961/lib-storage/index/maildir

Modified Files:
      Tag: branch_1_0
	maildir-keywords.c maildir-storage.c 
Log Message:
Added automatic upgrades from 0.99: .subscriptions and .customflags are
renamed to their new names automatically.



Index: maildir-keywords.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-keywords.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- maildir-keywords.c	26 Feb 2006 11:24:39 -0000	1.6
+++ maildir-keywords.c	4 Jul 2006 17:03:27 -0000	1.6.2.1
@@ -16,6 +16,7 @@
 #include "maildir-uidlist.h"
 #include "maildir-keywords.h"
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <utime.h>
@@ -76,6 +77,15 @@
 	p_clear(mk->pool);
 }
 
+static bool maildir_keywords_convert_099(struct maildir_keywords *mk)
+{
+	/* FIXME: for backwards compatibility only. remove this some day. */
+	const char *path;
+
+	path = t_strconcat(mk->mbox->control_dir, "/.customflags", NULL);
+	return rename(path, mk->path) == 0;
+}
+
 static int maildir_keywords_sync(struct maildir_keywords *mk)
 {
 	struct istream *input;
@@ -89,14 +99,18 @@
            errors. */
 
 	if (stat(mk->path, &st) < 0) {
-		if (errno == ENOENT) {
-			maildir_keywords_clear(mk);
-			mk->synced = TRUE;
-			return 0;
+		if (errno != ENOENT) {
+			mail_storage_set_critical(STORAGE(mk->mbox->storage),
+				"stat(%s) failed: %m", mk->path);
+			return -1;
 		}
-                mail_storage_set_critical(STORAGE(mk->mbox->storage),
-					  "stat(%s) failed: %m", mk->path);
-		return -1;
+
+		if (maildir_keywords_convert_099(mk))
+			return maildir_keywords_sync(mk);
+
+		maildir_keywords_clear(mk);
+		mk->synced = TRUE;
+		return 0;
 	}
 
 	if (st.st_mtime == mk->synced_mtime) {

Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.115.2.6
retrieving revision 1.115.2.7
diff -u -d -r1.115.2.6 -r1.115.2.7
--- maildir-storage.c	26 Jun 2006 17:48:19 -0000	1.115.2.6
+++ maildir-storage.c	4 Jul 2006 17:03:27 -0000	1.115.2.7
@@ -36,6 +36,24 @@
 
 static int verify_inbox(struct maildir_storage *storage);
 
+static void maildir_subscriptions_convert_099(struct maildir_storage *storage)
+{
+	/* FIXME: for backwards compatibility only. remove this some day. */
+	const char *path, *oldpath;
+	struct stat st;
+
+	path = t_strconcat(storage->control_dir != NULL ?
+			   storage->control_dir : INDEX_STORAGE(storage)->dir,
+			   "/" SUBSCRIPTION_FILE_NAME, NULL);
+	if (stat(path, &st) == 0 || errno != ENOENT)
+		return;
+
+	oldpath = t_strconcat(storage->control_dir != NULL ?
+			      storage->control_dir : INDEX_STORAGE(storage)->dir,
+			      "/.subscriptions", NULL);
+	(void)rename(oldpath, path);
+}
+
 static struct mail_storage *
 maildir_create(const char *data, const char *user,
 	       enum mail_storage_flags flags,
@@ -145,6 +163,8 @@
 	istorage->callbacks = p_new(pool, struct mail_storage_callbacks, 1);
 	index_storage_init(istorage, flags, lock_method);
 
+	maildir_subscriptions_convert_099(storage);
+
 	(void)verify_inbox(storage);
 	return STORAGE(storage);
 }



More information about the dovecot-cvs mailing list