[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c,1.48,1.49

cras at procontrol.fi cras at procontrol.fi
Mon May 12 09:44:07 EEST 2003


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

Modified Files:
	mbox-storage.c 
Log Message:
Don't give internal errors when trying to select, delete or rename
(non-existing) mailboxes under mbox.



Index: mbox-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- mbox-storage.c	8 May 2003 05:44:37 -0000	1.48
+++ mbox-storage.c	12 May 2003 05:44:05 -0000	1.49
@@ -403,7 +403,7 @@
 		(void)create_mbox_index_dirs(storage, name, TRUE);
 
 		return mbox_open(storage, name, readonly, fast);
-	} else if (errno == ENOENT) {
+	} else if (errno == ENOENT || errno == ENOTDIR) {
 		mail_storage_set_error(storage, "Mailbox doesn't exist: %s",
 				       name);
 		return NULL;
@@ -505,7 +505,7 @@
 
 	path = mbox_get_path(storage, name);
 	if (lstat(path, &st) < 0) {
-		if (errno == ENOENT) {
+		if (errno == ENOENT || errno == ENOTDIR) {
 			mail_storage_set_error(storage,
 					       "Mailbox doesn't exist: %s",
 					       name);
@@ -536,7 +536,7 @@
 
 	/* first unlink the mbox file */
 	if (unlink(path) < 0) {
-		if (errno == ENOENT) {
+		if (errno == ENOENT || errno == ENOTDIR) {
 			mail_storage_set_error(storage,
 					       "Mailbox doesn't exist: %s",
 					       name);
@@ -556,7 +556,7 @@
 	    unlink_directory(index_dir, TRUE) < 0 && errno != ENOENT) {
 		mail_storage_set_critical(storage, "unlink_directory(%s) "
 					  "failed: %m", index_dir);
-		return FALSE;
+		/* mailbox itself is deleted, so return success anyway */
 	}
 	return TRUE;
 }
@@ -600,6 +600,10 @@
 		mail_storage_set_error(storage,
 				       "Target mailbox already exists");
 		return FALSE;
+	} else if (errno == ENOENT || errno == ENOTDIR) {
+		mail_storage_set_error(storage, "Mailbox doesn't exist: %s",
+				       oldname);
+		return FALSE;
 	} else if (errno == EACCES) {
 		return mbox_permission_denied(storage);
 	} else {
@@ -611,8 +615,13 @@
 	/* we need to rename the index directory as well */
 	old_indexdir = mbox_get_index_dir(storage, oldname);
 	new_indexdir = mbox_get_index_dir(storage, newname);
-	if (old_indexdir != NULL)
-		(void)rename(old_indexdir, new_indexdir);
+	if (old_indexdir != NULL) {
+		if (rename(old_indexdir, new_indexdir) < 0) {
+			mail_storage_set_critical(storage,
+						  "rename(%s, %s) failed: %m",
+						  old_indexdir, new_indexdir);
+		}
+	}
 
 	return TRUE;
 }



More information about the dovecot-cvs mailing list