aboutsummaryrefslogtreecommitdiffstats
path: root/worker
diff options
context:
space:
mode:
authorJulian Pidancet <julian.pidancet@oracle.com>2022-10-03 19:16:26 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-03 21:07:59 +0200
commit150aa0f498b9780a40fdab815552c4c4230b5178 (patch)
tree49e4da8832d677863a177ec134fef8590dd8ae29 /worker
parent8cd4770f329c749c801630d1ec29c2765e60a8e6 (diff)
downloadaerc-150aa0f498b9780a40fdab815552c4c4230b5178.tar.gz
maildir: hide invalid folders
The maildir worker currently populates the list of mail folders by listing all the filesystem subdirectories in the maildir directory. Although there's no official specification for maildir subfolders, they should all have cur/ new/ and tmp/ subdirectories to be valid. This patch prevents directories that don't have those subdirectories present on the filesystem from appearing in the account folder list. This is useful for example to prevent ".notmuch" and ".notmuch/xapian" from showing up in the folder list if using notmuch to index emails while using aerc's maildir backend. Signed-off-by: Julian Pidancet <julian.pidancet@oracle.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker')
-rw-r--r--worker/maildir/container.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/worker/maildir/container.go b/worker/maildir/container.go
index 52bbf837..156b0af5 100644
--- a/worker/maildir/container.go
+++ b/worker/maildir/container.go
@@ -78,6 +78,13 @@ func (c *Container) ListFolders() ([]string, error) {
return nil
}
+ // Drop dirs that lack {new,tmp,cur} subdirs
+ for _, sub := range []string{"new", "tmp", "cur"} {
+ if _, err := os.Stat(filepath.Join(path, sub)); os.IsNotExist(err) {
+ return filepath.SkipDir
+ }
+ }
+
if c.maildirpp {
// In Maildir++ layout, mailboxes are stored in a single directory
// and prefixed with a dot, and subfolders are separated by dots.