diff --git a/imap/mailbox.c b/imap/mailbox.c index 775fc5c0c0..4a3e0d4c91 100644 --- a/imap/mailbox.c +++ b/imap/mailbox.c @@ -6568,7 +6568,7 @@ HIDDEN int mailbox_rename_nocopy(struct mailbox *oldmailbox, mbentry_t *tempmb = oldmailbox->mbentry; oldmailbox->local_cstate = newcstate; oldmailbox->mbentry = newmbentry; - r = mailbox_add_conversations(oldmailbox, /*silent*/0); + r = mailbox_add_conversations(oldmailbox, oldmailbox->silentchanges); oldmailbox->mbentry = tempmb; oldmailbox->local_cstate = tempcs; } @@ -6685,7 +6685,7 @@ HIDDEN int mailbox_rename_copy(struct mailbox *oldmailbox, if (oldcstate) r = mailbox_delete_conversations(oldmailbox); if (!r && newcstate) - r = mailbox_add_conversations(newmailbox, /*silent*/0); + r = mailbox_add_conversations(newmailbox, newmailbox->silentchanges); } if (r) goto fail; diff --git a/imap/mboxlist.c b/imap/mboxlist.c index 283ad86c0a..1f2f2b39a1 100644 --- a/imap/mboxlist.c +++ b/imap/mboxlist.c @@ -2299,6 +2299,7 @@ EXPORTED int mboxlist_deletemailbox(const char *name, int isadmin, int keep_intermediaries = flags & MBOXLIST_DELETE_KEEP_INTERMEDIARIES; int silent = flags & MBOXLIST_DELETE_SILENT; int unprotect_specialuse = flags & MBOXLIST_DELETE_UNPROTECT_SPECIALUSE; + int isentirely = flags & MBOXLIST_DELETE_ENTIRELY; init_internal(); @@ -2421,7 +2422,20 @@ EXPORTED int mboxlist_deletemailbox(const char *name, int isadmin, } if (r && !force) goto done; - if (!isremote && !mboxname_isdeletedmailbox(name, NULL)) { + /* delete underlying mailbox */ + if (!isremote && mailbox) { + /* only on a real delete do we delete from the remote end as well */ + sync_log_unmailbox(mailbox_name(mailbox)); + mboxevent_extract_mailbox(mboxevent, mailbox); + mboxevent_set_access(mboxevent, NULL, NULL, userid, mailbox_name(mailbox), 1); + + r = mailbox_delete(&mailbox); + /* abort event notification */ + if (r && mboxevent) + mboxevent_free(&mboxevent); + } + + if (!isremote && !isentirely && !mboxname_isdeletedmailbox(name, NULL)) { /* store a DELETED marker */ int haschildren = mboxlist_haschildren(name); mbentry_t *newmbentry = mboxlist_entry_create(); @@ -2464,21 +2478,6 @@ EXPORTED int mboxlist_deletemailbox(const char *name, int isadmin, if (r && !force) goto done; } - - /* delete underlying mailbox */ - if (!isremote && mailbox) { - /* only on a real delete do we delete from the remote end as well */ - sync_log_unmailbox(mailbox_name(mailbox)); - mboxevent_extract_mailbox(mboxevent, mailbox); - mboxevent_set_access(mboxevent, NULL, NULL, userid, mailbox_name(mailbox), 1); - - r = mailbox_delete(&mailbox); - /* abort event notification */ - if (r && mboxevent) - mboxevent_free(&mboxevent); - } - - done: mailbox_close(&mailbox); mboxlist_entry_free(&mbentry); diff --git a/imap/mboxlist.h b/imap/mboxlist.h index 45c6c5c13b..fa21355971 100644 --- a/imap/mboxlist.h +++ b/imap/mboxlist.h @@ -240,6 +240,8 @@ int mboxlist_createmailboxlock(const mbentry_t *mbentry, #define MBOXLIST_DELETE_SILENT (1<<4) /* unprotect_specialuse ignores the specialuse_protect config */ #define MBOXLIST_DELETE_UNPROTECT_SPECIALUSE (1<<5) +/* for sync_reset - wipe everything */ +#define MBOXLIST_DELETE_ENTIRELY (1<<6) /* delayed delete */ /* Translate delete into rename */ /* prepare MailboxDelete notification if mboxevent is not NULL */ diff --git a/imap/sync_reset.c b/imap/sync_reset.c index 404abb6168..42f67a804e 100644 --- a/imap/sync_reset.c +++ b/imap/sync_reset.c @@ -155,17 +155,13 @@ static int reset_single(const char *userid) for (i = mblist->count; i; i--) { const char *name = strarray_nth(mblist, i-1); int delflags = MBOXLIST_DELETE_FORCE | MBOXLIST_DELETE_SILENT | - MBOXLIST_DELETE_LOCALONLY; + MBOXLIST_DELETE_LOCALONLY | MBOXLIST_DELETE_ENTIRELY; r = mboxlist_deletemailbox(name, 1, sync_userid, sync_authstate, NULL, delflags); if (r == IMAP_MAILBOX_NONEXISTENT) { printf("skipping already removed mailbox %s\n", name); } else if (r) goto fail; - /* XXX - cheap and nasty hack around actually cleaning up the entry */ - r = mboxlist_deleteremote(name, NULL); - if (r == IMAP_MAILBOX_NONEXISTENT) r = 0; - if (r) goto fail; } if (mbentry) r = user_deletedata(mbentry, 1);