# Don't give up if index_me() throws an error. Not wildly happy about # mboxlist_findall which can run for several days in any case. # diff -udNr cyrus-imapd-2.3.14/imap/squatter.c cyrus-imapd/imap/squatter.c --- cyrus-imapd-2.3.14/imap/squatter.c 2009-02-09 05:01:59.000000000 +0000 +++ cyrus-imapd/imap/squatter.c 2009-03-26 20:21:19.000000000 +0000 @@ -589,6 +589,9 @@ printf("error opening looking up %s: %s\n", extname, error_message(r)); } + syslog(LOG_INFO, "error opening looking up %s: %s\n", + extname, error_message(r)); + return 1; } if (mbtype & MBTYPE_REMOTE) return 0; @@ -639,6 +642,8 @@ if (verbose) { printf("error opening %s: %s\n", extname, error_message(r)); } + syslog(LOG_INFO, "error opening %s: %s\n", extname, error_message(r)); + return 1; } @@ -648,6 +653,9 @@ if (verbose) { printf("error locking index %s: %s\n", extname, error_message(r)); } + syslog(LOG_INFO, "error locking index %s: %s\n", + extname, error_message(r)); + mailbox_close(&m); return 1; } @@ -690,6 +698,36 @@ return 0; } +struct tmpnode { + struct tmpnode *next; + char *name; +}; +struct tmplist { + struct tmpnode *head; + struct tmpnode *tail; +}; + +static int addmbox(char *name, + int matchlen __attribute__((unused)), + int maycreate __attribute__((unused)), + void *rock) +{ + struct tmplist **lptr = (struct tmplist **) rock; + struct tmplist *l = *lptr; + struct tmpnode *n = xmalloc(sizeof (struct tmpnode)); + + n->next = NULL; + n->name = xstrdup(name); + + if (l->head) { + l->tail = l->tail->next = n; + } else { + l->head = l->tail = n; + } + + return 0; +} + int main(int argc, char **argv) { int opt; @@ -755,6 +793,12 @@ start_stats(&total_stats); if (optind == argc) { + struct tmplist *l; + struct tmpnode *current; + + l = xmalloc(sizeof(struct tmplist)); + l->head = l->tail = NULL; + if (rflag) { fprintf(stderr, "please specify a mailbox to recurse from\n"); exit(EC_USAGE); @@ -762,7 +806,12 @@ assert(!rflag); strlcpy(buf, "*", sizeof(buf)); (*squat_namespace.mboxlist_findall)(&squat_namespace, buf, 1, - 0, 0, index_me, &use_annot); + 0, 0, addmbox, &l); + + for (current = l->head; current; current = current->next) { + index_me(current->name, strlen(current->name), 0, &use_annot); + /* Ignore errors: most will be mailboxes moving around */ + } } for (i = optind; i < argc; i++) {