Browse Source

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>.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
4d75c45507
  1. 2
      NEWS
  2. 2
      TODO
  3. 2
      src/common.h
  4. 6
      src/main.c
  5. 5
      src/main_sync.c
  6. 6
      src/mbsync.1
  7. 2
      src/sync.c

2
NEWS

@ -27,6 +27,8 @@ Added support for mirroring deletions more accurately.
Added --dry-run option. Added --dry-run option.
Added --ext-exit option.
[1.4.0] [1.4.0]
The 'isync' compatibility wrapper was removed. The 'isync' compatibility wrapper was removed.

2
TODO

@ -25,8 +25,6 @@ add alternative treatments of expired messages. ExpiredMessageMode: Prune
separate folder - ArchiveSuffix, default .archive). separate folder - ArchiveSuffix, default .archive).
add support for event notification callbacks. 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 make it possible to have different mailbox names for far and near side in
Patterns. Patterns.

2
src/common.h

@ -115,6 +115,8 @@ BIT_ENUM(
DRYRUN, DRYRUN,
EXT_EXIT,
ZERODELAY, ZERODELAY,
KEEPJOURNAL, KEEPJOURNAL,
FORCEJOURNAL, FORCEJOURNAL,

6
src/main.c

@ -47,6 +47,7 @@ PACKAGE " " VERSION " - mailbox synchronizer\n"
" -c, --config CONFIG read an alternate config file (default: ~/." EXE "rc)\n" " -c, --config CONFIG read an alternate config file (default: ~/." EXE "rc)\n"
" -D, --debug debugging modes (see manual)\n" " -D, --debug debugging modes (see manual)\n"
" -y, --dry-run do not actually modify anything\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" " -V, --verbose display what is happening\n"
" -q, --quiet don't display progress counters\n" " -q, --quiet don't display progress counters\n"
" -v, --version display version\n" " -v, --version display version\n"
@ -221,6 +222,8 @@ main( int argc, char **argv )
DFlags |= op; DFlags |= op;
} else if (!strcmp( opt, "dry-run" )) { } else if (!strcmp( opt, "dry-run" )) {
DFlags |= DRYRUN; DFlags |= DRYRUN;
} else if (!strcmp( opt, "ext-exit" )) {
DFlags |= EXT_EXIT;
} else if (!strcmp( opt, "pull" )) { } else if (!strcmp( opt, "pull" )) {
cops |= XOP_PULL, mvars->ops[F] |= XOP_HAVE_TYPE; cops |= XOP_PULL, mvars->ops[F] |= XOP_HAVE_TYPE;
} else if (!strcmp( opt, "push" )) { } else if (!strcmp( opt, "push" )) {
@ -461,6 +464,9 @@ main( int argc, char **argv )
case 'y': case 'y':
DFlags |= DRYRUN; DFlags |= DRYRUN;
break; break;
case 'e':
DFlags |= EXT_EXIT;
break;
case 'T': case 'T':
for (; *ochar; ) { for (; *ochar; ) {
switch (*ochar++) { switch (*ochar++) {

5
src/main_sync.c

@ -388,6 +388,11 @@ sync_chans( core_vars_t *cvars, char **argv )
if (!cvars->list) { if (!cvars->list) {
flushn(); flushn();
summary(); 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;
}
} }
} }

6
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 operations are determined, but no modifications are actually made
to either the mailboxes or the state files. to either the mailboxes or the state files.
.TP .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 \fB-V\fR, \fB--verbose\fR
Enable \fIverbose\fR mode, which displays what is currently happening. Enable \fIverbose\fR mode, which displays what is currently happening.
.TP .TP

2
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) if ((svars->chan->ops[t] & (OP_EXPUNGE | OP_EXPUNGE_SOLO)) && !(DFlags & FAKEEXPUNGE)
/*&& !(svars->state[t] & ST_TRASH_BAD)*/) { /*&& !(svars->state[t] & ST_TRASH_BAD)*/) {
if (Verbosity >= TERSE) { if (Verbosity >= TERSE || (DFlags & EXT_EXIT)) {
if (svars->opts[t] & OPEN_UID_EXPUNGE) { if (svars->opts[t] & OPEN_UID_EXPUNGE) {
for (message_t *tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) { for (message_t *tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) {
if (tmsg->status & M_DEAD) if (tmsg->status & M_DEAD)

Loading…
Cancel
Save