Hi!

On Sat, 2015-09-05 at 14:18:21 +0100, Ian Campbell wrote:
> On Sat, 2015-09-05 at 13:53 +0200, Guillem Jover wrote:
> > On Fri, 2015-09-04 at 10:38:09 +0100, Ian Campbell wrote:
> > > The change to Master being the primary thing. This results in the:
> > > 
> > > [Account]
> > > |-INBOX
> > > |- PATCHES
> > > |  |- WIP
> > > |  `- FOO
> > > `- Cronspam
> > > 
> > > maildir hierarchy which I noted in Message #75 I'd be happy to switch to 
> > > if
> > > necessary.
> > 
> > Right, and thanks for the update, unfortunately that's not a conformant
> > Maildir++ layout,
> 
> FWIW the disk layout which Evolution displays as above is:
> 
>     Maildir/{cur,tmp,new} # AKA "INBOX"
>     Maildir/.PATCHES/{cur,tmp,new}
>     Maildir/.PATCHES.WIP/{cur,tmp,new}
>     Maildir/.PATCHES.FOO/{cur,tmp,new}
>     Maildir/.Cronspam/{cur,tmp,new}

Ah, right, sorry yes that to me seems to be proper Maildir++,

> Just mentioning for clarity in case you thought it was:
> 
>     Maildir/{cur,tmp,new} # AKA "INBOX"
>     Maildir/PATCHES/{cur,tmp,new}

Exactly. :)

> because I thought the first (with the dots) _was_ compliant Maildir++.

Yes, I think so.

> > > NB: I'm still tinkering with things, so I'm not 100% sure this is correct,
> > > but on first glance it looks so and I'm also not sure if it is applicable
> > > to the issue in your context but I hope it turns out to be helpful!
> > 
> > I've not had time to look into this again, but once I do, I guess I'll
> > try to prepare a patch, post it here, and if it gets rejected run with
> > a local fork. Either that or try to discover how to properly configure
> > the program to do what I want, in case it is really possible. :)

Ok, so I tried your recipe, and didn't fully work for me, and ended
up having a look, because had already spent enough time again messing
with the config file that it was getting a bit frustrating.

Here's a couple of patches I prepared that seem to do what I'd expect,
and I've been running with those from git master [C], but only with
«Sync Pull» for now. The first adds quite some verbosity to be able to
see what's actually going on, the second "fixes" the Maildir++ support
for me. Once I've tested it more, I'll probably be preparing local
packages with the patches.

  [C] commit 167964933f42d32f1cc2a119453e71c5048e86e2

Thanks,
Guillem
From c4b51b5c8df236d272987820e801db20bd78d398 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Sun, 6 Sep 2015 21:47:57 +0200
Subject: [PATCH 1/2] XXX: Add more verbosity

---
 src/drv_maildir.c |  3 +++
 src/main.c        | 26 +++++++++++++++++++++++++-
 src/sync.c        |  2 +-
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index a91b7cc..74fdd81 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -125,6 +125,8 @@ maildir_join_path( maildir_store_conf_t *conf, const char *prefix, const char *b
 	int pl, bl, n, sub = 0;
 	char c;
 
+	info(" maildir join source = '%s'\n", box);
+
 	pl = strlen( prefix );
 	for (bl = 0, n = 0; (c = box[bl]); bl++)
 		if (c == '/') {
@@ -165,6 +167,7 @@ maildir_join_path( maildir_store_conf_t *conf, const char *prefix, const char *b
 		}
 	}
 	*p = 0;
+	info(" maildir join dest = '%s'\n", out);
 	return out;
 }
 
diff --git a/src/main.c b/src/main.c
index c8c3bf2..03c2bad 100644
--- a/src/main.c
+++ b/src/main.c
@@ -215,6 +215,13 @@ cmp_box_names( const void *a, const void *b )
 	return strcmp( as, bs );
 }
 
+static void
+print_boxes_list(string_list_t *boxes, int box)
+{
+	for (; boxes; boxes = boxes->next)
+		info("  box[%d] name = %s\n", box, boxes->string);
+}
+
 static char **
 filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns )
 {
@@ -225,8 +232,10 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns
 
 	pfxl = prefix ? strlen( prefix ) : 0;
 	for (; boxes; boxes = boxes->next) {
-		if (!starts_with( boxes->string, -1, prefix, pfxl ))
+		if (!starts_with( boxes->string, -1, prefix, pfxl )) {
+			info("  skipping prefix: %s\n", boxes->string);
 			continue;
+		}
 		fnot = 1;
 		for (cpat = patterns; cpat; cpat = cpat->next) {
 			ps = cpat->string;
@@ -240,6 +249,8 @@ filter_boxes( string_list_t *boxes, const char *prefix, string_list_t *patterns
 				break;
 			}
 		}
+		if (fnot)
+			info("  ignoring pattern: %s\n", boxes->string);
 		if (!fnot) {
 			if (num + 1 >= rnum)
 				boxarr = nfrealloc( boxarr, (rnum = (rnum + 10) * 2) * sizeof(*boxarr) );
@@ -817,6 +828,15 @@ sync_chans( main_vars_t *mvars, int ent )
 			mvars->chanptr->boxlist = 2;
 			boxes[M] = filter_boxes( mvars->ctx[M]->boxes, mvars->chan->boxes[M], mvars->chan->patterns );
 			boxes[S] = filter_boxes( mvars->ctx[S]->boxes, mvars->chan->boxes[S], mvars->chan->patterns );
+
+			print_boxes_list(mvars->ctx[M]->boxes, M);
+			print_boxes_list(mvars->ctx[S]->boxes, S);
+
+			for (mb = 0; boxes[M][mb]; mb++)
+				info(" box: M=%s\n", boxes[M][mb]);
+			for (sb = 0; boxes[S][sb]; sb++)
+				info(" box: S=%s\n", boxes[S][sb]);
+
 			mboxapp = &mvars->chanptr->boxes;
 			for (mb = sb = 0; ; ) {
 				char *mname = boxes[M] ? boxes[M][mb] : 0;
@@ -824,18 +844,22 @@ sync_chans( main_vars_t *mvars, int ent )
 				if (!mname && !sname)
 					break;
 				mbox = nfmalloc( sizeof(*mbox) );
+				info(" check boxes m=%s s=%s\n", mname, sname);
 				if (!(cmp = !mname - !sname) && !(cmp = cmp_box_names( &mname, &sname ))) {
+					info(" check both present\n");
 					mbox->name = mname;
 					free( sname );
 					mbox->present[M] = mbox->present[S] = BOX_PRESENT;
 					mb++;
 					sb++;
 				} else if (cmp < 0) {
+					info(" check master present\n");
 					mbox->name = mname;
 					mbox->present[M] = BOX_PRESENT;
 					mbox->present[S] = (!mb && !strcmp( mbox->name, "INBOX" )) ? BOX_PRESENT : BOX_ABSENT;
 					mb++;
 				} else {
+					info(" check slave present\n");
 					mbox->name = sname;
 					mbox->present[M] = (!sb && !strcmp( mbox->name, "INBOX" )) ? BOX_PRESENT : BOX_ABSENT;
 					mbox->present[S] = BOX_PRESENT;
diff --git a/src/sync.c b/src/sync.c
index 9672734..cb2669e 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -1057,7 +1057,7 @@ box_confirmed2( sync_vars_t *svars, int t )
 			}
 			if (svars->existing) {
 				if (!(svars->chan->ops[1-t] & OP_REMOVE)) {
-					error( "Error: channel %s: %s %s cannot be opened.\n",
+					error( "Error: channel %s: %s %s cannot be opened (removed).\n",
 					       svars->chan->name, str_ms[t], svars->orig_name[t] );
 					goto bail;
 				}
-- 
2.5.1

From 016cd3d52ebb66867ee89024272300c8df8df6b5 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@hadrons.org>
Date: Sun, 6 Sep 2015 21:47:36 +0200
Subject: [PATCH 2/2] maildir: Fix Maildir++ support

---
 src/drv_maildir.c | 13 ++++++-------
 src/mbsync.1      |  2 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c
index 74fdd81..a3a37fd 100644
--- a/src/drv_maildir.c
+++ b/src/drv_maildir.c
@@ -122,7 +122,7 @@ static char *
 maildir_join_path( maildir_store_conf_t *conf, const char *prefix, const char *box )
 {
 	char *out, *p;
-	int pl, bl, n, sub = 0;
+	int pl, bl, n;
 	char c;
 
 	info(" maildir join source = '%s'\n", box);
@@ -141,9 +141,11 @@ maildir_join_path( maildir_store_conf_t *conf, const char *prefix, const char *b
 			       conf->gen.name, box );
 			return 0;
 		}
-	out = nfmalloc( pl + bl + n + 1 );
+	out = nfmalloc( pl + bl + n + 2 );
 	memcpy( out, prefix, pl );
 	p = out + pl;
+	if (conf->sub_style == SUB_MAILDIRPP)
+		*p++ = '.';
 	while ((c = *box++)) {
 		if (c == '/') {
 			switch (conf->sub_style) {
@@ -151,10 +153,6 @@ maildir_join_path( maildir_store_conf_t *conf, const char *prefix, const char *b
 				*p++ = c;
 				break;
 			case SUB_MAILDIRPP:
-				if (!sub) {
-					sub = 1;
-					*p++ = c;
-				}
 				*p++ = '.';
 				break;
 			case SUB_LEGACY:
@@ -391,11 +389,12 @@ static int
 maildir_list_path( store_t *gctx, int flags, const char *inbox )
 {
 	char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX];
+	int isBox = ((maildir_store_conf_t *)gctx->conf)->sub_style == SUB_MAILDIRPP;
 
 	if (maildir_ensure_path( (maildir_store_conf_t *)gctx->conf ) < 0)
 		return -1;
 	return maildir_list_recurse(
-	        gctx, 0, flags, inbox, inbox ? strlen( inbox ) : 0, 0, 0,
+	        gctx, isBox, flags, inbox, inbox ? strlen( inbox ) : 0, 0, 0,
 	        path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", gctx->conf->path ),
 	        name, 0 );
 }
diff --git a/src/mbsync.1 b/src/mbsync.1
index daa8d41..72adc64 100644
--- a/src/mbsync.1
+++ b/src/mbsync.1
@@ -267,7 +267,7 @@ the styles will yield the following on-disk paths:
 \fBVerbatim\fR - \fItop/sub/subsub\fR
 (this is the style you probably want to use)
 .br
-\fBMaildir++\fR - \fItop/.sub.subsub\fR
+\fBMaildir++\fR - \fI.top.sub.subsub\fR
 (this style is compatible with Courier and Dovecot - but note that
 the mailbox metadata format is \fInot\fR compatible)
 .br
-- 
2.5.1

Reply via email to