changeset 1200:57f6989a6b8d HEAD

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.
author Timo Sirainen <tss@iki.fi>
date Wed, 19 Feb 2003 22:16:01 +0200
parents 88c0d1c2b3c3
children e04c2b01ecb2
files src/lib-storage/index/maildir/maildir-storage.c
diffstat 1 files changed, 12 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-storage.c	Wed Feb 19 22:01:55 2003 +0200
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Wed Feb 19 22:16:01 2003 +0200
@@ -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;