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.
This commit is contained in:
Oswald Buddenhagen
2022-06-03 17:35:18 +02:00
parent acd6b4b0b8
commit b4e8b29397
2 changed files with 14 additions and 2 deletions

View File

@@ -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/" ) );
}

View File

@@ -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