|
Two problems, both visible in the first real run of the moved script.
Every line was logged twice. The script writes to the log through tee,
and the user's crontab also ended in ">> mailsync.log 2>&1", so both put
the same output there. Reproduced: without the caller's redirect one run
writes a single RUN START, with it, two. The crontab redirect goes away
and the script keeps owning the log, which is what makes it behave the
same however it is invoked. A comment in the header now says so, since
the obvious cron line is the one that breaks it.
The internal size-based rotation is removed outright.
/etc/logrotate.d/mailsync already owns this file and keeps seven
compressed days, and the two were fighting: the script's
"mv $LOGFILE $LOGFILE.1" overwrites whatever logrotate had just placed
at .1, which is why that file was 357K and uncompressed while .2 through
.5 were properly gzipped. logrotate is better at this in every respect,
including recreating the file with the right ownership, so the script
should not have a second opinion.
Verified against stub mbsync and notmuch in a fake HOME: one RUN START
per run, stdout and the log agree, no rotation performed by the script,
and a failing mbsync or notmuch still produces its own exit code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
|
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 <noreply@anthropic.com>
|