isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 4d75c45507b302d301fee5d6ae413b559f32222a
parent edc901b7afc55d5ec55c4d642fbe6419e02b791c
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Tue, 10 May 2022 14:11:36 +0200

add --ext-exit option

this is only a partial solution for reporting changes, but it's
adequate if the goal is merely triggering a bulk action, like
re-indexing the local store.

inspired by patches posted by Yuri D'Elia <wavexx@thregr.org>.

Diffstat:
MNEWS | 2++
MTODO | 2--
Msrc/common.h | 2++
Msrc/main.c | 6++++++
Msrc/main_sync.c | 5+++++
Msrc/mbsync.1 | 6++++++
Msrc/sync.c | 2+-
7 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS @@ -27,6 +27,8 @@ Added support for mirroring deletions more accurately. Added --dry-run option. +Added --ext-exit option. + [1.4.0] The 'isync' compatibility wrapper was removed. diff --git a/TODO b/TODO @@ -25,8 +25,6 @@ add alternative treatments of expired messages. ExpiredMessageMode: Prune separate folder - ArchiveSuffix, default .archive). add support for event notification callbacks. -it would be also possible to report more differentiated exit codes, but -that seems too limiting in the general case. make it possible to have different mailbox names for far and near side in Patterns. diff --git a/src/common.h b/src/common.h @@ -115,6 +115,8 @@ BIT_ENUM( DRYRUN, + EXT_EXIT, + ZERODELAY, KEEPJOURNAL, FORCEJOURNAL, diff --git a/src/main.c b/src/main.c @@ -47,6 +47,7 @@ PACKAGE " " VERSION " - mailbox synchronizer\n" " -c, --config CONFIG read an alternate config file (default: ~/." EXE "rc)\n" " -D, --debug debugging modes (see manual)\n" " -y, --dry-run do not actually modify anything\n" +" -e, --ext-exit return extended exit code\n" " -V, --verbose display what is happening\n" " -q, --quiet don't display progress counters\n" " -v, --version display version\n" @@ -221,6 +222,8 @@ main( int argc, char **argv ) DFlags |= op; } else if (!strcmp( opt, "dry-run" )) { DFlags |= DRYRUN; + } else if (!strcmp( opt, "ext-exit" )) { + DFlags |= EXT_EXIT; } else if (!strcmp( opt, "pull" )) { cops |= XOP_PULL, mvars->ops[F] |= XOP_HAVE_TYPE; } else if (!strcmp( opt, "push" )) { @@ -461,6 +464,9 @@ main( int argc, char **argv ) case 'y': DFlags |= DRYRUN; break; + case 'e': + DFlags |= EXT_EXIT; + break; case 'T': for (; *ochar; ) { switch (*ochar++) { diff --git a/src/main_sync.c b/src/main_sync.c @@ -388,6 +388,11 @@ sync_chans( core_vars_t *cvars, char **argv ) if (!cvars->list) { flushn(); summary(); + if (DFlags & EXT_EXIT) { + for (int t = 0; t < 2; t++) + if (new_done[t] || flags_done[t] || trash_done[t] || expunge_done[t]) + cvars->ret |= 32 << t; + } } } diff --git a/src/mbsync.1 b/src/mbsync.1 @@ -79,6 +79,12 @@ Enter simulation mode: the Channel status is queried and all required operations are determined, but no modifications are actually made to either the mailboxes or the state files. .TP +\fB-e\fR, \fB--ext-exit\fR +Return an extended exit code: Add 32 resp. 64 to the code if any +modifications were made on the far resp. near side. +An error may be reported at the same time, so the code may be for example +65 if some changes were successfully pulled, while others failed. +.TP \fB-V\fR, \fB--verbose\fR Enable \fIverbose\fR mode, which displays what is currently happening. .TP diff --git a/src/sync.c b/src/sync.c @@ -1776,7 +1776,7 @@ sync_close( sync_vars_t *svars, int t ) if ((svars->chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) && !(DFlags & FAKEEXPUNGE) /*&& !(svars->state[t] & ST_TRASH_BAD)*/) { - if (Verbosity >= TERSE) { + if (Verbosity >= TERSE || (DFlags & EXT_EXIT)) { if (svars->opts[t] & OPEN_UID_EXPUNGE) { for (message_t *tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) { if (tmsg->status & M_DEAD)