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

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


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

diffstat:

1 file changed, 14 insertions(+), 3 deletions(-)
src/lib-storage/index/maildir/maildir-storage.c |   17 ++++++++++++++---

diffs (35 lines):

diff -r 2b462faf9867 -r aaa2e8397de4 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Sun May 27 16:45:26 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Wed May 30 15:19:19 2007 +0300
@@ -751,7 +751,7 @@ static int maildir_mailbox_delete(struct
 	   never see partially deleted mailboxes. */
 	src = maildir_get_path(storage, name);
 	dest = maildir_get_unlink_dest(storage, name);
-	if (stat(src, &st) != 0 && errno == ENOENT) {
+	if (lstat(src, &st) != 0 && errno == ENOENT) {
 		mail_storage_set_error(_storage,
 			MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND, name);
 		return -1;
@@ -788,9 +788,20 @@ static int maildir_mailbox_delete(struct
 		}
 	}
 
+	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;
+	}
+
 	if (dest == NULL) {
-		/* absolute maildir path, delete the directory directly
-		   without any renaming */
+		/* a) absolute maildir path, delete the directory directly
+		   without any renaming
+		   b) not a directory (symlink most likely) */
 		dest = src;
 	} else {
 		count = 0;


More information about the dovecot-cvs mailing list