Improve initial folder list sync

* The initial folder list sync has been worst-case O(n**2); with
  this change it is now O(n)
* Also, we only save each Mailbox once, which saves a lot of extra
  disk thrashing
* Assume generic user-created folders hold mail; this simplifies the
  code greatly and solves a number of user issues.  In the case that
  we're wrong (I've never seen it), there's really no harm done

Change-Id: I20321b2708ce3e8ebbe647116a787b26d115c3bf
5 files changed