[dovecot-cvs] dovecot: Deleting symlinked maildirs didn't work.

dovecot at dovecot.org dovecot at dovecot.org
Wed May 30 15:19:46 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/c981e66cc78e
changeset: 5668:c981e66cc78e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 30 15:19:20 2007 +0300
description:
Deleting symlinked maildirs didn't work.

diffstat:

1 file changed, 11 insertions(+), 1 deletion(-)
src/lib-storage/index/maildir/maildir-storage.c |   12 +++++++++++-

diffs (25 lines):

diff -r 052f000ad273 -r c981e66cc78e src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Tue May 29 20:04:22 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Wed May 30 15:19:20 2007 +0300
@@ -740,10 +740,20 @@ maildir_list_delete_mailbox(struct mailb
 
 	/* check if the mailbox actually exists */
 	src = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_MAILBOX);
-	if (stat(src, &st) != 0 && errno == ENOENT) {
+	if (lstat(src, &st) != 0 && errno == ENOENT) {
 		mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
 			T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
 		return -1;
+	}
+
+	if (!S_ISDIR(st.st_mode)) {
+		/* a symlink most likely */
+		if (unlink(src) < 0 && errno != ENOENT) {
+			mail_storage_set_critical(_storage,
+				"unlink(%s) failed: %m", src);
+			return -1;
+		}
+		return 0;
 	}
 
 	dest = maildir_get_unlink_dest(list, name);


More information about the dovecot-cvs mailing list