From 74d1da2755ff8e1a47bda676fab7b84e910ef738 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 4 Aug 2026 12:04:31 +0200 Subject: feat(sync): bring mailsync.sh here, print to stdout, exit truthfully The reference sync script lived in the companion mailctl project, which documents that it never calls it: sync and organization are separate there on purpose. qtmaildir is the only thing that runs it programmatically, and two of its behaviours were live bugs here, so it belongs in this repo where the constraints on it are. It printed nothing a caller could see. Everything was redirected to $LOGFILE, so MailSync captured an empty stream and the sync log pane stayed blank, a known limitation carried since 0.1.0. It now writes to both through tee: cron keeps its log, and the pane has something to show. It also ended in an unconditional exit 0, discarding statuses it had already computed. qtmaildir believes that exit code: a failed mbsync reported success, cleared the unsynced-changes count, and would have allowed a sync-on-exit to quit over a sync that never happened, which is exactly the case the exit prompt exists to prevent. It now exits with mbsync's status, or notmuch's when mbsync succeeded. The statuses move through files rather than shell variables because the run block is piped into tee, which puts it in a subshell where an assignment does not survive. Verified against stub mbsync and notmuch binaries in a fake HOME, so no mail or database was touched: output reaches stdout, the log still gets every line, and a failing mbsync or notmuch produces its own exit code rather than zero. Both properties are now recorded in CLAUDE.md, since they exist for this application's sake and an edit that looks like a cleanup would remove them. Co-Authored-By: Claude Opus 5 --- CLAUDE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'CLAUDE.md') diff --git a/CLAUDE.md b/CLAUDE.md index 694852f..9eb21a4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -75,6 +75,16 @@ combined `thread:a or thread:b` query rather than one query per thread. The only escape hatch is `general/notmuch_config`, pointing at an alternate notmuch config. Per-account subdirectories *are* configured, since notmuch does not model accounts at all. +**The sync script lives here, in `assets/mailsync.sh`.** It moved from the +companion `mailctl` project, which documents that it never calls it: the script +is `mbsync` plus `notmuch new` with a lock, and qtmaildir is the only thing that +runs it programmatically. Two properties exist for this application's sake and +must survive any edit. It **prints to stdout as well as its log file**, because +`MailSync` shows what the command prints and a self-redirecting script leaves +the pane empty; and it **exits with the real status**, because a `0` from a +failed sync makes qtmaildir report success, clear the unsynced-changes count, +and quit on a sync that never happened. + **Every user-facing string is translatable.** Wrap UI text in `tr()`, including strings that are only ever shown in passing: status bar messages, tooltips, dialog prose, completion descriptions. Query syntax itself is not user-facing text — notmuch keywords -- cgit v1.2.3