Browse Source

*** exclude INBOX* in Patterns from prefixing

*** this is redundant with asymmetric Patterns, which can come with
their own prefixes.

amends cf0f32f8.
wip/INBOX-patterns-prefixing
Oswald Buddenhagen 3 years ago
parent
commit
e35c16cac7
  1. 22
      src/main_sync.c

22
src/main_sync.c

@ -159,8 +159,12 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns
uint pfxl = prefix ? strlen( prefix ) : 0; uint pfxl = prefix ? strlen( prefix ) : 0;
for (; boxes; boxes = boxes->next) { for (; boxes; boxes = boxes->next) {
if (!starts_with( boxes->string, -1, prefix, pfxl )) const char *box = boxes->string;
if (!is_inbox( box )) {
if (!starts_with( box, -1, prefix, pfxl ))
continue; continue;
box += pfxl;
}
uint fnot = 1, not; uint fnot = 1, not;
for (string_list_t *cpat = patterns; cpat; cpat = cpat->next) { for (string_list_t *cpat = patterns; cpat; cpat = cpat->next) {
const char *ps = cpat->string; const char *ps = cpat->string;
@ -170,7 +174,7 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns
} else { } else {
not = 0; not = 0;
} }
if (matches( boxes->string + pfxl, ps )) { if (matches( box, ps )) {
fnot = not; fnot = not;
break; break;
} }
@ -178,7 +182,7 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns
if (!fnot) { if (!fnot) {
if (num + 1 >= rnum) if (num + 1 >= rnum)
boxarr = nfrealloc( boxarr, (rnum = (rnum + 10) * 2) * sizeof(*boxarr) ); boxarr = nfrealloc( boxarr, (rnum = (rnum + 10) * 2) * sizeof(*boxarr) );
boxarr[num++] = nfstrdup( boxes->string + pfxl ); boxarr[num++] = nfstrdup( box );
boxarr[num] = NULL; boxarr[num] = NULL;
} }
} }
@ -523,13 +527,11 @@ store_connected( int sts, void *aux )
for (string_list_t *cpat = mvars->chan->patterns; cpat; cpat = cpat->next) { for (string_list_t *cpat = mvars->chan->patterns; cpat; cpat = cpat->next) {
const char *pat = cpat->string; const char *pat = cpat->string;
if (*pat != '!') { if (*pat != '!') {
char buf[8];
int bufl = snprintf( buf, sizeof(buf), "%s%s", nz( mvars->chan->boxes[t], "" ), pat );
int flags = 0; int flags = 0;
// Partial matches like "INB*" or even "*" are not considered, // Partial matches like "INB*" or even "*" are not considered,
// except implicity when the INBOX lives under Path. // except implicity when the INBOX lives under Path.
if (starts_with( buf, bufl, "INBOX", 5 )) { if (starts_with( pat, -1, "INBOX", 5 )) {
char c = buf[5]; char c = pat[5];
if (!c) { if (!c) {
// User really wants the INBOX. // User really wants the INBOX.
flags |= LIST_INBOX; flags |= LIST_INBOX;
@ -549,8 +551,8 @@ store_connected( int sts, void *aux )
} else { } else {
flags |= LIST_PATH; flags |= LIST_PATH;
} }
debug( "pattern '%s' (effective '%s'): %sPath, %sINBOX\n", debug( "pattern '%s': %sPath, %sINBOX\n",
pat, buf, (flags & LIST_PATH) ? "" : "no ", (flags & LIST_INBOX) ? "" : "no "); pat, (flags & LIST_PATH) ? "" : "no ", (flags & LIST_INBOX) ? "" : "no ");
cflags |= flags; cflags |= flags;
} }
} }
@ -675,7 +677,7 @@ do_sync_boxes( main_vars_t *mvars )
break; break;
mvars->boxptr = mbox->next; mvars->boxptr = mbox->next;
mvars->box_done = 0; mvars->box_done = 0;
if (mvars->chan->boxes[F] || mvars->chan->boxes[N]) { if ((mvars->chan->boxes[F] || mvars->chan->boxes[N]) && !is_inbox( mbox->name )) {
const char *fpfx = nz( mvars->chan->boxes[F], "" ); const char *fpfx = nz( mvars->chan->boxes[F], "" );
const char *npfx = nz( mvars->chan->boxes[N], "" ); const char *npfx = nz( mvars->chan->boxes[N], "" );
if (mvars->cvars->list) { if (mvars->cvars->list) {

Loading…
Cancel
Save