changeset 5668:c981e66cc78e HEAD

Deleting symlinked maildirs didn't work.
author Timo Sirainen <tss@iki.fi>
date Wed, 30 May 2007 15:19:20 +0300
parents 052f000ad273
children c53d0698d56f
files src/lib-storage/index/maildir/maildir-storage.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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,12 +740,22 @@
 
 	/* 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);
 	if (dest == NULL) {
 		/* delete the directory directly without any renaming */