[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c,1.28,1.29

cras at procontrol.fi cras at procontrol.fi
Wed Feb 19 22:16:03 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory danu:/tmp/cvs-serv3847/lib-storage/index/maildir

Modified Files:
	maildir-storage.c 
Log Message:
We don't really need the cur, new and tmp symlinks in .INBOX/ dir. Also
don't even try to support renaming INBOX since we can't make it atomic.



Index: maildir-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- maildir-storage.c	19 Feb 2003 19:55:27 -0000	1.28
+++ maildir-storage.c	19 Feb 2003 20:16:01 -0000	1.29
@@ -125,6 +125,9 @@
 	if (full_filesystem_access && (*name == '/' || *name == '~'))
 		return maildir_get_absolute_path(name);
 
+	if (strcasecmp(name, "INBOX") == 0)
+		return storage->dir;
+
 	return t_strconcat(storage->dir, "/.", name, NULL);
 }
 
@@ -175,31 +178,19 @@
 
 static int verify_inbox(struct mail_storage *storage)
 {
-	const char **tmp, *src, *dest, *inbox;
+	const char *inbox;
 
 	/* first make sure the cur/ new/ and tmp/ dirs exist in root dir */
 	(void)create_maildir(storage->dir, TRUE);
 
 	/* create the .INBOX directory */
-	inbox = maildir_get_path(storage, "INBOX");
+	inbox = t_strconcat(storage->dir, "/.INBOX", NULL);
 	if (mkdir(inbox, CREATE_MODE) == -1 && errno != EEXIST) {
 		mail_storage_set_critical(storage, "Can't create directory "
 					  "%s: %m", inbox);
 		return FALSE;
 	}
 
-	/* then symlink the cur/ new/ and tmp/ into the .INBOX/ directory */
-	for (tmp = maildirs; *tmp != NULL; tmp++) {
-		src = t_strconcat("../", *tmp, NULL);
-		dest = t_strconcat(inbox, "/", *tmp, NULL);
-
-		if (symlink(src, dest) == -1 && errno != EEXIST) {
-			mail_storage_set_critical(storage, "symlink(%s, %s) "
-						  "failed: %m", src, dest);
-			return FALSE;
-		}
-	}
-
 	/* make sure the index directories exist */
 	return create_index_dir(storage, "INBOX");
 }
@@ -378,37 +369,6 @@
 	return TRUE;
 }
 
-static int move_inbox_data(struct mail_storage *storage, const char *newdir)
-{
-	const char **tmp, *oldpath, *newpath;
-
-	/* newpath points to the destination folder directory, which contains
-	   symlinks to real INBOX directories. unlink() the symlinks and
-	   move the real cur/ directory here. */
-	for (tmp = maildirs; *tmp != NULL; tmp++) {
-		newpath = t_strconcat(newdir, "/", *tmp, NULL);
-		if (unlink(newpath) == -1 && errno != EEXIST) {
-			mail_storage_set_critical(storage,
-						  "unlink(%s) failed: %m",
-						  newpath);
-			return FALSE;
-		}
-	}
-
-	oldpath = t_strconcat(storage->dir, "/cur", NULL);
-	newpath = t_strconcat(newdir, "/cur", NULL);
-
-	if (rename(oldpath, newpath) != 0) {
-		mail_storage_set_critical(storage, "rename(%s, %s) failed: %m",
-					  oldpath, newpath);
-		return FALSE;
-	}
-
-	/* create back the cur/ directory for INBOX */
-	(void)mkdir(oldpath, CREATE_MODE);
-	return TRUE;
-}
-
 static int rename_indexes(struct mail_storage *storage,
 			  const char *oldname, const char *newname)
 {
@@ -497,20 +457,19 @@
 		return FALSE;
 	}
 
-	/* NOTE: renaming INBOX works just fine with us, it's simply created
-	   the next time it's needed. Only problem with it is that it's not
-	   atomic operation but that can't be really helped.
+	if (strcmp(oldname, "INBOX") == 0) {
+		mail_storage_set_error(storage,
+				       "Renaming INBOX isn't supported.");
+		return FALSE;
+	}
 
-	   NOTE: it's possible to rename a nonexisting folder which has
+	/* NOTE: it's possible to rename a nonexisting folder which has
 	   subfolders. In that case we should ignore the rename() error. */
 	oldpath = maildir_get_path(storage, oldname);
 	newpath = maildir_get_path(storage, newname);
 
 	ret = rename(oldpath, newpath);
-	if (ret == 0 || (errno == ENOENT && strcmp(oldname, "INBOX") != 0)) {
-		if (strcmp(oldname, "INBOX") == 0)
-			return move_inbox_data(storage, newpath);
-
+	if (ret == 0 || errno == ENOENT) {
 		if (!rename_indexes(storage, oldname, newname))
 			return FALSE;
 




More information about the dovecot-cvs mailing list