Expand description
Fetching new mail, read-only, into the accountโs Maildir.
The first sync brings the last days of each folder (sync_days, 14 by
default), so the Porch shows soon. Then what arrives, by UID, the inbox
first, and, a round at a time, everything older, newest first: all your
mail is kept here, and the history setting only chooses what the window
shows. Older mail never takes the diskโs reserve (disk::room): it waits,
and the window says so. Where sync stopped is kept per account and folder
in $XDG_STATE_HOME/sioul/sync/<id>.toml, after every batch, so an
interrupted sync resumes where it stopped.
watch keeps the inbox open with IDLE (RFC 2177), so a code reaches you
within seconds of reaching your provider.
Structsยง
- Arrived ๐
- A message as the server gave it, before Sioul checks and stores it.
- Control
- How a watcher is told to stop, or to fetch now instead of waiting, and at what pace.
- Deadline ๐
- The end of a wait, on both clocks: the wall clock counts a phoneโs sleep, the monotonic clock keeps a wall clock put back from stretching it.
- Folder
State ๐ - Parked ๐
- A watcher parked after a lasting error: it waits for a nudge (a new
password, โSync nowโ, the app back) instead of ending, then tries again;
a refused password, unchanged, not before
REFUSED_AGAIN, unless asked to (Control::retry). - Reach ๐
- How far back a folder was fetched: since a day (Unix seconds), or everything.
- Report
- What one sync brought.
- Sync
State ๐ - Where sync stopped, per folder.
Enumsยง
- Kept
- How much of a folder is kept here: all of it, all of it since a day (Unix seconds), or nothing known (never fetched, left on the server, or fetched before Sioul kept how far back). A search asks the server for the rest.
Constantsยง
- BATCH ๐
- Messages per FETCH: small enough to save progress often.
- FETCH ๐
- FIRST_
PAUSE ๐ - The first wait before reconnecting; it doubles up to ten minutes.
- IDLE ๐
- IDLE is renewed this often: RFC 2177 asks for less than 29 minutes, and a connection that died silently is noticed sooner.
- INBOX ๐
- LONGEST_
PAUSE ๐ - LOOK ๐
- How often a long wait looks at the wall clock: the monotonic clock, which timers count, stops while a phone sleeps.
- OLDER_
PER_ ๐ROUND - Older messages fetched per round, so new mail never waits long behind them.
- POLL ๐
- Without IDLE, Sioul looks this often.
- REALTIME ๐
- Real time: every folder fetched this often, for a code or a password you wait for.
- REFUSED_
AGAIN ๐ - A refused password is tried again, unchanged, this long after at the soonest, however often the watcher is nudged: retries can lock an account.
- SLOW ๐
- Paces longer than this keep no connection open between fetches: IDLE would bring the inbox sooner than wished (RFC 2177 renews under 29 minutes).
Functionsยง
- backfill ๐
- The older messages of a folder, those not here yet, a round at a time, newest first, each round sized first so the disk keeps its reserve; the folder remembers once it holds everything.
- block_
on ๐ - fetch_
batch ๐ - One FETCH: every message of
set. BODY.PEEK leaves the \Seen flag alone. - fetch_
folder ๐ - Fetches a folderโs new messages into its Maildir, then (
full) brings back what changed there on the server and older mail. One fetch at a time per account, across processes too (the window andsioul sync): otherwise both would see the same new UIDs and write each message twice. - fetch_
new ๐ - Fetches the inboxโs new messages into the Maildir.
- first_
window ๐ - The first day a first sync brings: the first window (
sync_days); older mail follows, a round at a time. - forget_
folder_ ๐state - Where a folderโs sync stopped, forgotten: the next sync of it starts over.
- imap_
date ๐ - A day as IMAP writes dates: โ18-Sep-2026โ, with English month names whatever your language (RFC 9051 ยง9, date-month).
- inbox
- The inboxโs arrivals alone, in one connection and without IDLE: what a
phoneโs background service fetches at its rhythm, while Sioul is closed
(crates/sioul-app/src/steps.rs). One fetch at a time per account, across
processes too, as for every fetch (
fetch_folder). - keep_
open ๐ - One connection, kept as long as it lives: fetch, wait for news, fetch again.
- kept
- How much of
folder(its server name) this device holds, as its last sync left it. - local_
uids ๐ - The UIDs of a folderโs messages kept here, for this UIDVALIDITY.
- lock ๐
- An exclusive lock on a file, released when the returned file is dropped.
- maildir_
flags ๐ - IMAPโs system flags as Maildirโs letters (https://cr.yp.to/proto/maildir.html),
and the keywords kept,
$Junkand$NotJunk, as Dovecotโs lowercase letters (maildir::KEYWORDS): what you or a mail client said of a message, which the spam filter learns from and the Porch heeds.reconcilekeeps them in step. - other_
folders ๐ - Lists the folders, keeps the list, and fetches every folder but the inbox; returns the files written, and whether older mail waits for room.
- runtime ๐
- sizes_
of ๐ - The sizes of messages on the server (RFC822.SIZE), by UID, before fetching them.
- store_
checked ๐ - Checks each message (SPF, DKIM, DMARCโฆ, see
verify) and writes it into the Maildir. - sync
- Fetches what is new since the last sync, in every folder; the first time,
the last
sync_daysdays. The report is the inboxโs. - test
- Logs in and opens the inbox read-only: the number of messages in it.
- to_
fetch ๐ - The UIDs to fetch of those found, oldest first, and the newest of those
here already (else
last_uid). Here already: a sync stopped between storing mail and saving where it stopped, or whose state was lost, finds them again, and they are not stored twice. - wait ๐
- Waits
length, or less when stopped or nudged; on the wall clock too (seeDeadline). Whether it was nudged. - watch
- Keeps the inbox open and fetches what arrives, until stopped (see
Control). Every sync is reported, even an empty one, and every error, before trying again; after a lasting one (a refused login, seeSyncError::is_lasting) it waits for a nudge, then tries again with the password kept then (seeParked). - woken ๐
- Returns when the watcher is stopped or nudged.