IMAP: Make sure both the sync state and UID mapping are updated in sync

The code was originally modifying the UID mapping and the mailbox sync state
separately and at an undefined time. In addition to that, the HIGHESTMODSEQ,
MODSEQ and RECENT updates were not propagated at certain time, leading to
excessive network traffic even for stuff which was already transferred before.

This change makes sure that we never do crazy stuff like throwing away the UID
mapping while retaining the sync state, or perhaps updating the sync state
before all the UIDs have arrived, etc. The ultimate goal of this patch is that
no data are transferred twice and that the local cache is always kept in a
consistent state.

After this patch is applied, you might see a once-per-folder resynchronization
and a complaint on the stderr about the cache being inconsistent. This means
that some previous session, perhaps an older version of Trojita, has corrupted
the cache and we cannot trust it anymore. That's unavoidable and also a right
thing to do :).

REVIEW: 113891