ju1ius / SavedSearchInSubFolders

A Thunderbird add-on that automatically extends all the saved searches to subfolders of selected folders.
2 stars 1 forks source link

Option to select leaf folders only #3

Open pschoenbach opened 10 years ago

pschoenbach commented 10 years ago

Please add an option that allows to add leaf folders (the folders that actually contain messages, not those containing further subfolders) only.

Otherwise, one get's tons of "Mailbox doesn't exist" errors on some IMAP servers (i.e. dovecot).

ju1ius commented 10 years ago

Hi, can you post some details about these errors ? Like your console output ?

pschoenbach commented 10 years ago

Create a structure like e.g.:

A

A and B are not searchable, and if you try, the IMAP server will return an error (at least if using Maildir mailbox). C and D are leaf folders containing messages and can be searched.

ju1ius commented 10 years ago

A and B are not searchable

What do you mean by that ?

and if you try, the IMAP server will return an error

What is the error returned ?

I like to archive my emails on a regular basis, so I have a very similar folder layout, that looks like this:

┌─ INBOX
├──── Sent
├──┬─ Archives
│  ├──── 2013
│  └──┬─ 2014
│     ├──── 2014-01
│     ├──── 2014-02
│     └──── 2014-03
├──── Junk
└──── Trash

I have several virtual folders that search both in INBOX and Archives (all folders are on the server). Neither the Archives nor the "year" (2013, 2014...) folders contain messages, and I am not getting those errors (my server is Dovecot too).

Couldn't it be a misconfiguration issue ? Do the folder exist on your filesystem, your server, both ? Do the server allow folders containing both messages and subfolders ?

pschoenbach commented 10 years ago

I guess, the problem is the following: If the mailbox format is Maildir, not mbox, then, in your example, there is only a folder called e.g. ".Archives.2014.2014-01" but neither a folder ".Archives" nor ".Archives.2014".

The error message is "Mailbox doesn't exist."

ju1ius commented 10 years ago

Hi,

In order to allow me to better understand the issue, could you do the following:

Thanks.

pschoenbach commented 10 years ago
# Folder Info
# ====================
Name: Mailarchiv
URI: imap://xxx@mail.server.org/Archiv/Mailarchiv
URL: imap://xxx@mail.server.org/Archiv/Mailarchiv
Flags: Mail, ImapBox, ImapPersonal, ImapNoselect
Has subfolders: true
Number of messages: 0
Number of subfolders: 10
Number of messages (including subfolders): 0
Local path: D:\Users\pschoenb\AppData\Roaming\Thunderbird\Profiles\5isg7fye.default\ImapMail\mail.robustsoft.de\Archiv.sbd\Mailarchiv
Charset: ISO-8859-15
Size on disk: 0
Allows sub folder creation ?: true
Allows renaming ?: true
Allows compacting ?: true
[IMAP] Verified as online folder ?: true
[IMAP] Online name: Archiv.Mailarchiv
[IMAP] Is namespace?: false
[IMAP] Hierarchy delimiter: .

# ServerInfo
# ====================
URI: imap://xxx@mail.server.org
Host: mail.server.org
User: xxx
Port: 143
Remote type: imap
Local type: imap
Local path: D:\Users\pschoenb\AppData\Roaming\Thunderbird\Profiles\5isg7fye.default\ImapMail\mail.server.org
Allows search operations ?: true
Allows sub folder creation ?: true
Supports filters ?: true
Allows message filing ?: true
Allows compacting folders ?: true
Allows undo delete ?: true
[IMAP] Admin URL: null
[IMAP] Server directory: null
[IMAP] Supports dual-use folders: true
[IMAP] Max number of connections: 20
[IMAP] Personal namespace: ""
[IMAP] Public namespace: null
[IMAP] Other users namespace: null
[IMAP] Is AOL server ?: false
[IMAP] Is GMail server ?: false

Seems ok, still, I am getting these popup errors when doing a saved search on the server i.e. online.

ju1ius commented 10 years ago

Ok thanks! By checking the folder flags, I see ImapNoSelect (this mailbox has the imap \Noselect flag set). Doesn't it look like this bug ? Could you also post the debug info for a folder that doesn't produce the error ?

pschoenbach commented 10 years ago

Yes. Could we maybe create a workaround by including only selectable folders?

ju1ius commented 10 years ago

Of course! But first I need to be sure it's the actual issue. Do the offending folders appear greyed-out in the folder pane ? Could you also post the debug info for a folder that doesn't produce the error ?

pschoenbach commented 10 years ago

Yes, it is greyed-out.

Second output:

# Folder Info
# ====================
Name: Empfangen
URI: imap://xxx@mail.example.com/Aktuell/Kuerzlich/Empfangen
URL: imap://xxx@mail.example.com/Aktuell/Kuerzlich/Empfangen
Flags: Mail, Elided, ImapBox, ImapPersonal, Offline
Has subfolders: false
Number of messages: 160
Local path: D:\Users\pschoenb\AppData\Roaming\Thunderbird\Profiles\5isg7fye.default\ImapMail\mail.example.com\Aktuell.sbd\Kuerzlich.sbd\Empfangen
Charset: ISO-8859-15
Size on disk: 65820159
Allows sub folder creation ?: true
Allows renaming ?: true
Allows compacting ?: true
[IMAP] Verified as online folder ?: true
[IMAP] Online name: Aktuell.Kuerzlich.Empfangen
[IMAP] Is namespace?: false
[IMAP] Hierarchy delimiter: .

# ServerInfo
# ====================
URI: imap://xxx@mail.example.com
Host: mail.example.com
User: xxx
Port: 143
Remote type: imap
Local type: imap
Local path: D:\Users\pschoenb\AppData\Roaming\Thunderbird\Profiles\5isg7fye.default\ImapMail\mail.example.com
Allows search operations ?: true
Allows sub folder creation ?: true
Supports filters ?: true
Allows message filing ?: true
Allows compacting folders ?: true
Allows undo delete ?: true
[IMAP] Admin URL: null
[IMAP] Server directory: null
[IMAP] Supports dual-use folders: true
[IMAP] Max number of connections: 20
[IMAP] Personal namespace: ""
[IMAP] Public namespace: null
[IMAP] Other users namespace: null
[IMAP] Is AOL server ?: false
[IMAP] Is GMail server ?: false
ju1ius commented 10 years ago

Could we maybe create a workaround by including only selectable folders?

Thinking about it, I don't think it would be a good idea to automatically exclude folders from the hierarchy. In your case, folders A & B would be excluded, and would you add an E folder in B, then the E folder wouldn't be automatically added to the virtual folder's search targets, which kind of defeat the whole point of the addon.

It's a Thunderbird bug, that should not issue SELECT commands on Noselect mailboxes. It would be better if you reopened this bug. Even if I manage to find a sane workaround.

pschoenbach commented 10 years ago

Did that. Can't we reevaluate selectability if we find new folders?

ju1ius commented 10 years ago

Did that.

;-)

Can't we reevaluate selectability if we find new folders?

Yes and no.

Yes: selectability can be evaluated at any time by checking if the ImapNoSelect flag is set on a folder.

No: let me explain how the addon operates. When you save your changes in the virtual folder properties dialog, the addon adds the subfolders of each folder selected. It also sets up a listener that gets called each time a new folder is added (in any account). Then it walks through all virtual folders, fetches their search folders, and if the added folder is a descendant of one of those, it adds the new folder to the search folders list. So when the listener gets called with a newly added folder, one of it's ancestors MUST be present in the search folders list. Otherwise it is ignored.

It means that for a workaround like this to work, you need at least one selectable ancestor in the folder hierarchy. So in a case like this:

┌─ INBOX
├──── Sent
├──┬─ Archives
│  └──┬─ 2014
│     ├──── 2014-01
├──── Junk
└──── Trash

If INBOX.Archives and INBOX.Archives.2014 are marked as Noselect and you ignore them, you would have to add the whole INBOX to the search list, which is probably not what you want...

The only solution I can think of in your case would be to add a context menu to the virtual folder properties dialog, with a command to add subfolders of the selected folder(s) (possibly excluding Noselect folders, or adding only leaf folders). But then you would have to disable the "watch folders" preference and manually update the virtual folder each time you archive your mails. Which isn't such a pain unless, like me, you have dozens of virtual folders...

ju1ius commented 10 years ago

Yes I tought of that one, but maintaining a separate database of possibly hundreds of folders is really non-trivial, and I'm afraid it would increase the addon complexity exponentially. Testing things in Thunderbird is such a pain in the b*tt !

I'll look into the GLODA documentation to see if it can support custom flags.

pschoenbach commented 10 years ago

How about checking if the new folder is a descendant of any folder marked for searching in the saved search?

ju1ius commented 10 years ago

How about checking if the new folder is a descendant of any folder marked for searching in the saved search?

That's already what it does. See my previous comment

pschoenbach commented 10 years ago

Would it work if intermediate descendants are not selectable?

ju1ius commented 10 years ago

Yes, excluding Noselect folders would only work if they have a selectable ancestor.

pschoenbach commented 10 years ago

Wouldn't it be sufficient if it had an ancestor which is marked for searching, be it selectable or not?

ju1ius commented 10 years ago

Well, if it's not selectable, you'll still have those error messages... Albeit less of them.

pschoenbach commented 10 years ago

Not really, we just could reevaluate selectability on the branch between the marked an the new folder, and then, we won't lose folders. Am I wrong?

pschoenbach commented 10 years ago

I opened a new bug at https://bugzilla.mozilla.org/show_bug.cgi?id=1017005