Skip to content

Commit

Permalink
Add support for delayed delete mode in sync_apply_unmailbox() and
Browse files Browse the repository at this point in the history
sync_apply_unuser()

Signed-off-by: Jeroen van Meeuwen (Apheleia IT) <[email protected]>
  • Loading branch information
Jeroen van Meeuwen (Apheleia IT) authored and Jeroen van Meeuwen (Kolab Systems) committed Dec 1, 2022
1 parent 622c6e4 commit 2fc93bc
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions imap/sync_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -3635,16 +3635,28 @@ int sync_get_user(struct dlist *kin, struct sync_state *sstate)
int sync_apply_unmailbox(struct dlist *kin, struct sync_state *sstate)
{
const char *mboxname = kin->sval;
int r;

struct mboxlock *namespacelock = mboxname_usernamespacelock(mboxname);

/* Delete with admin privileges */
int delflags = MBOXLIST_DELETE_FORCE | MBOXLIST_DELETE_SILENT;
if (sstate->flags & SYNC_FLAG_LOCALONLY)
delflags |= MBOXLIST_DELETE_LOCALONLY;
int r = mboxlist_deletemailbox(mboxname, sstate->userisadmin,

if (!mboxlist_delayed_delete_isenabled()) {
r = mboxlist_deletemailbox(mboxname, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);
} else if (mboxname_isdeletedmailbox(mboxname, NULL)) {
r = mboxlist_deletemailbox(mboxname, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);
} else {
r = mboxlist_delayed_deletemailbox(mboxname, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);
}

mboxname_release(&namespacelock);

Expand Down Expand Up @@ -3977,11 +3989,24 @@ int sync_apply_unuser(struct dlist *kin, struct sync_state *sstate)
int delflags = MBOXLIST_DELETE_FORCE;
if (sstate->flags & SYNC_FLAG_LOCALONLY)
delflags |= MBOXLIST_DELETE_LOCALONLY;

for (i = list->count; i; i--) {
const char *name = strarray_nth(list, i-1);
r = mboxlist_deletemailbox(name, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);

if (!mboxlist_delayed_delete_isenabled()) {
r = mboxlist_deletemailbox(name, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);
} else if (mboxname_isdeletedmailbox(name, NULL)) {
r = mboxlist_deletemailbox(name, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);
} else {
r = mboxlist_delayed_deletemailbox(name, sstate->userisadmin,
sstate->userid, sstate->authstate,
NULL, delflags);
}

if (r) goto done;
}

Expand Down

0 comments on commit 2fc93bc

Please sign in to comment.