if (mbox.isTrackingSync() && info.itemIds.size() > 0) DbMailItem.writeTombstone(mbox, info);
if (mbox.isTrackingSync() && !info.itemIds.isEmpty()) DbMailItem.writeTombstone(mbox, info.itemIds);
    static void purgeMessages(Mailbox mbox, Folder folder, int beforeDate) throws ServiceException {        if (beforeDate <= 0 || beforeDate >= mbox.getOperationTimestamp())            return;        boolean allFolders = (folder == null);        List<Folder> folders = (allFolders ? null : folder.getSubfolderHierarchy());        // get the full list of things that are being removed        PendingDelete info = DbMailItem.getLeafNodes(mbox, folders, beforeDate, allFolders);        if (info.itemIds.isEmpty())            return;        mbox.markItemDeleted(info.itemIds);        // update message counts        for (Map.Entry<Integer, DbMailItem.LocationCount> entry : info.messages.entrySet()) {            int folderID = entry.getKey();            int msgCount = entry.getValue().count;            mbox.getFolderById(folderID).updateSize(-msgCount);        }        // update the mailbox's size        mbox.updateSize(-info.size);        mbox.updateContactCount(-info.contacts);        // update unread counts on folders and tags        List<UnderlyingData> unreadData = DbMailItem.getById(mbox, info.unreadIds, TYPE_MESSAGE);        for (UnderlyingData data : unreadData)            mbox.getItem(data).updateUnread(-1);        // remove the deleted item(s) from the mailbox's cache        if (!info.itemIds.isEmpty()) {            info.cascadeIds = DbMailItem.markDeletionTargets(mbox, info.itemIds);            mbox.purge(TYPE_CONVERSATION);        }        // actually delete the items from the DB        DbMailItem.delete(mbox, info.itemIds);        mbox.markOtherItemDirty(info);        // also delete any conversations whose messages have all been removed        if (info.cascadeIds != null && !info.cascadeIds.isEmpty()) {            DbMailItem.delete(mbox, info.cascadeIds);            mbox.markItemDeleted(info.cascadeIds);            info.itemIds.addAll(info.cascadeIds);        }        // deal with index sharing        if (!info.sharedIndex.isEmpty())            DbMailItem.resolveSharedIndex(mbox, info);        // write a deletion record for later sync        if (mbox.isTrackingSync() && info.itemIds.size() > 0)            DbMailItem.writeTombstone(mbox, info);        // don't actually delete the blobs or index entries here; wait until after the commit    }