From 01194fa2c48019f1dcbdfefac94f8fd5f8e38122 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 7 Aug 2026 19:17:59 +0200 Subject: feat(sync): sync only the accounts with unsynced edits A sync ran mbsync -a regardless of what changed, so tagging mail in one account fetched all of them. The account set was not a parameter anywhere on the path: MailSync::start() took no arguments and the script hardcoded -a, so nothing between a tag edit and mbsync carried which account changed. Track which accounts have edits and pass their mbsync channels through to the script, which now takes channel names and falls back to -a when given none. An empty set means all accounts, per the request: a sync with nothing pending is a fetch, and narrowing that to wherever the last edit landed would quietly stop collecting mail everywhere else. The channel is a new optional per-account key rather than the section key. The two names genuinely diverge, because a QSettings section key may carry dots that the channel does not, and mbsync treats an unknown channel as fatal rather than skipping it, so key-as-channel would fail those accounts' syncs outright rather than degrade. It defaults to the key, so accounts whose two names already agree need no config change. The edited-account set is deliberately not netted the way the pending-edit map is: that map tracks the index, where a tag removed and re-added leaves nothing outstanding, while this tracks the mail store, where both writes have already renamed files that mbsync still has to propagate. It is also snapshotted before flushHeldEdits(), which inserts into it synchronously rather than on a queued reply, so a successful sync cannot clear accounts whose edits it never carried. Closes item 49. Co-Authored-By: Claude Opus 5 --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 13002d8..e49f7e6 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ maildir = work-mail ; relative to notmuch's database.path drafts = Drafts ; recorded for v2; unused today label = W ; optional chip text; defaults to the key color = #2f6fa8 ; optional chip colour; generated when unset +channel = work ; optional mbsync channel; defaults to the key [account.personal] name = Your Name @@ -311,6 +312,34 @@ Two things any replacement has to get right, both learned the hard way: a click landing inside one is routine. qtmaildir reports 75 as "a sync is already running" and leaves the log pane alone, where any other non-zero code raises an error. +- **Accept channel names as arguments, and sync everything when given none.** + qtmaildir passes the mbsync channels of the accounts it has edited, so a sync + after tagging one account's mail does not fetch all of them. A script that + ignores its arguments still works, it just always syncs everything. + +### Per-account sync + +When tag changes are outstanding, a sync passes only the affected accounts' +channel names to the command. When nothing is outstanding the run is a plain +fetch and no names are passed, so every account is synced: narrowing a fetch to +wherever the last edit happened to be would quietly stop collecting mail +everywhere else. + +The name passed is the **mbsync channel**, which is not always the account's +section key. `[account.mail-first.last]` may well be the channel +`mail-firstlast`, since a section key can carry dots that the channel does not. +Set `channel` in the account section wherever the two differ: + +```ini +[account.mail-first.last] +maildir = mail-first.last +channel = mail-firstlast +``` + +Getting this wrong is not silent: `mbsync` fails on a channel it does not know, +and qtmaildir reports the sync as failed rather than clearing the count. An +account tag with no matching section falls back to syncing everything, since +skipping it would strand its edits with nothing to say so. While a sync this window started is running, the status bar shows an indeterminate progress bar. It is deliberately not a percentage: `mbsync` -- cgit v1.2.3