if (rmdir_path) {
if (rmdir(path) == 0)
unlinked_something = TRUE;
- else if (errno != ENOENT && errno != ENOTEMPTY) {
+ else if (errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
path);
return -1;
}
while (strcmp(path, root_dir) != 0) {
if (rmdir(path) < 0 && errno != ENOENT) {
- if (errno == ENOTEMPTY)
+ if (errno == ENOTEMPTY || errno == EEXIST)
return;
mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
/* try to delete the parent directory */
path = mailbox_list_get_path(list, name,
MAILBOX_LIST_PATH_TYPE_DIR);
- if (rmdir(path) < 0 && errno != ENOENT && errno != ENOTEMPTY) {
+ if (rmdir(path) < 0 && errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(list, "rmdir(%s) failed: %m",
path);
}
if (errno == ENOENT) {
mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND,
T_MAIL_ERR_MAILBOX_NOT_FOUND(name));
- } else if (errno == ENOTEMPTY) {
+ } else if (errno == ENOTEMPTY || errno == EEXIST) {
/* mbox workaround: if only .imap/ directory is preventing the
deletion, remove it */
child_name = t_strdup_printf("%s%cchild", name,
}
if (rmdir_parent && (p = strrchr(oldpath, '/')) != NULL) {
oldpath = t_strdup_until(oldpath, p);
- if (rmdir(oldpath) < 0 &&
- errno != ENOENT && errno != ENOTEMPTY) {
+ if (rmdir(oldpath) < 0 && errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(oldlist,
"rmdir(%s) failed: %m", oldpath);
}
MAILBOX_LIST_PATH_TYPE_DIR);
if (rmdir(oldpath) == 0)
rmdir_parent = TRUE;
- else if (errno != ENOENT && errno != ENOTEMPTY) {
+ else if (errno != ENOENT &&
+ errno != ENOTEMPTY && errno != EEXIST) {
mailbox_list_set_critical(oldlist,
"rmdir(%s) failed: %m", oldpath);
}