Is reMail Rocket Science?
Here’s a rough overview of the data flow in reMail: Emails are stored in sqlite databases named email-X.edb, where X is a number. Each timeslice covers roughly 3 days, as controlled by EmailProcessor.dbNumForDate. There is a central contacts db which is used to autocomplete names. Each contact entry also includes the youngest and oldest time slice in which emails from that contact occur. This way, search results for people are served up almost instantly. There is a UID DB (somewhat misnamed) which stores hashes (not ids) of already downloaded emails so we can avoid downloading them again. The code includes a slightly modified Sqlite3 with better search snippet generation (the snippets generated by sqlite’s built-in fts3 module are too short for our purposes, and don’t include which of the fields matched). SyncManager also kicks off running ImapSync, which in turn uses ImapFolderWorker to download each each email in that folder (newest emails first). ImapFolderWorker calls the SyncManag