Refactor nsMsgLocalMailFolder messsage copying.
Categories
(MailNews Core :: Backend, task)
Tracking
(Not tracked)
People
(Reporter: benc, Assigned: benc)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/plain
|
Details |
There's a lot of cleanup and simplification to be done in the nsLocalMailFolder message copy code. At the moment it's really hard to follow, and very brittle.
- It uses different paths for single and multiple message copies
CopyMessageTo()
vsCopyMessagesTo()
. These could be unified. - The nsLocalMailCopyState is waaay too complicated and it's really unclear which bits are used by which code paths.
- The use of the nsICopyMessageListener callbacks is unclear and they seem to be invoked rather inconsistently.
- There's a lot more that needs to be picked through.
Assignee | ||
Comment 1•3 years ago
|
||
See also:
Bug 1717375 - The short-cut used for direct maildir->maildir copying was doubling up the nsIMsgCopyServicerListener
callbacks. (OnStartCopy()/OnStopCopy()).
The maildir->maildir path also
- duplicates code for doing POP3 deletes (when moving)
- ignores some other things it should be doing (there's some keyword-related stuff)
- entirely ignores the nsLocalCopyState data
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
I think Bug 1749276 might be a symptom of the complexity of message-copying code.
Comment 3•2 years ago
|
||
I saw a weird bug that popped up a continuous string of alerts about unable to copy something to Local Folder. I was unable to do or change anything because the message would pop right back up. The error occurred here: https://searchfox.org/comm-central/rev/1de28ff4bff691f753d7b30b2f7d7fcc9dc546a4/mailnews/local/src/nsLocalMailFolder.cpp#1976
I wasn't trying to copy anything but I found a filter I had entered, just for testing something, to match all and copy to a Local Folder, but no new messages arrived in the filter source Inbox so don't know why a copy was attempted.
I couldn't disable the filter due to the continuous popups so I killed TB and changed the alert call at line 1976 to just a printf and let it run again and this freed it up and I disabled the filter.
In the console I saw thousands of my printf's but right before they occurred there is an assert looking for the leading mbox specific "From " thing:
https://searchfox.org/comm-central/rev/1de28ff4bff691f753d7b30b2f7d7fcc9dc546a4/mailnews/local/src/nsLocalMailFolder.cpp#1966. For some reason in the past I had converted my Local Folders from mbox to maildir format and don't remember why. So at this point in the code I would assume that looking for a "From " is not really needed.
But the error alert seems to be due to a null m_fileString. Then I found the reference to this bug so reporting it here rather than in a new bug: https://searchfox.org/comm-central/rev/1de28ff4bff691f753d7b30b2f7d7fcc9dc546a4/mailnews/local/src/nsLocalMailFolder.cpp#1875
I couldn't duplicate the errors when I enabled the filter and let it copy to Local Folder again.
Assignee | ||
Comment 4•2 years ago
|
||
I finally sat down and traced my way through the code path taken during a local folder -> local folder message copy operation.
I'm posting my notes mainly for my own reference, when I go to refactoring this stuff.
It's already been a really useful exercise to me but I suspect it'd be of limited use to anyone else... other than for entertainment and/or sheer horror ;-)
The notes cut a lot of corners to try and keep a straight narrative path through the code, and it doesn't really convey the sheer intertwinedness of everything. So - to me anyway - these notes suggest some obvious refactors that would simplify things a lot, but actually putting them into practice is tricky without breaking other aspects.
Assignee | ||
Updated•1 year ago
|
Description
•