From b4e8b2939780f5aa77c1fb411d32437376d40d68 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 3 Jun 2022 17:35:18 +0200 Subject: [PATCH] fix handling of maildir Path directly overlapping Inbox one might want to set `Inbox ~/Maildir` and `Path ~/Maildir/` to get a self-contained ~/Maildir without resorting to `SubFolders Maildir++`, though logical sub-folders are possible only with `SubFolders Legacy`. also document that nesting Path into Inbox is supported in the first place; amends 98bd2b11. --- src/drv_maildir.c | 15 +++++++++++++-- src/mbsync.1 | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 0f94519..0fd0835 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -451,10 +451,21 @@ maildir_list_inbox( maildir_store_t *ctx, int flags ) ctx->listed |= LIST_INBOX; add_string_list( &ctx->boxes, "INBOX" ); + uint pathLen = nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ctx->conf->inbox ); const char *basePath = ctx->conf->path; + uint basePathLen = 0; + if (basePath) { + basePathLen = strlen( basePath ) - 1; + // In verbatim mode, Path "steals" the sub-folders from INBOX + // if it is identical to Inbox. In legacy mode, subdirs are + // dot-prefixed, so no mutual exclusion is necessary. + if (ctx->conf->sub_style == SUB_VERBATIM && + equals( path, pathLen, basePath, basePathLen )) { + return 0; + } + } return maildir_list_recurse( - ctx, 1, flags, NULL, 0, basePath, basePath ? strlen( basePath ) - 1 : 0, - path, nfsnprintf( path, _POSIX_PATH_MAX, "%s/", ctx->conf->inbox ), + ctx, 1, flags, NULL, 0, basePath, basePathLen, path, pathLen, name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX/" ) ); } diff --git a/src/mbsync.1 b/src/mbsync.1 index 8a8b01f..5a1c3bc 100644 --- a/src/mbsync.1 +++ b/src/mbsync.1 @@ -274,6 +274,7 @@ See \fBRECOMMENDATIONS\fR below. \fBInbox\fR \fIpath\fR The location of the \fBINBOX\fR. This is \fInot\fR relative to \fBPath\fR, but it is allowed to place the \fBINBOX\fR inside the \fBPath\fR. +Conversely, it is also possible to put \fBPath\fR inside the \fBINBOX\fR. (Default: \fI~/Maildir\fR) . .TP