Closed Bug 1428104 Opened 6 years ago Closed 6 years ago

Renaming IMAP folders that have subfolders may fail (Seamonkey only)

Categories

(MailNews Core :: Networking: IMAP, defect)

defect
Not set
normal

Tracking

(thunderbird_esr5260+ fixed, seamonkey2.53 fixed)

RESOLVED FIXED
Thunderbird 60.0
Tracking Status
thunderbird_esr52 60+ fixed
seamonkey2.53 --- fixed

People

(Reporter: neil, Assigned: neil)

References

Details

Attachments

(1 file)

After renaming a folder, the IMAP protocol then attempts to subscribe to the new folder name and unsubscribe from the old folder name. When renaming a leaf folder, any errors from the subscribe operations are ignored (presumably in case the server already updated the subscriptions automatically). However if the folder being renamed contains subfolders then errors from the subscribe operations cause the whole rename to bail, leaving the client out of sync. Side effects include UI not being up-to-date and .msf files not being renamed.
Attached patch 1428104.diffSplinter Review
(The suite change is a port of a fix that Thunderbird incidentally happened to make as part of their front-end rewrite. It prevents the .msf for the old folder from being recreated.)
Attachment #8939903 - Flags: review?(rkent)
Kent hasn't done any reviews in ages, so you might want to find a different reviewer.
Attachment #8939903 - Flags: review?(rkent) → review?(Pidgeot18)
Another bad choice of reviewer :-(
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

Neil, neither Kent not Joshua do timely reviews (if at all) these days. Gene has been very active in IMAP lately, so I'm asking him to try this out. I'm happy to r+ the change if I can get his positive feedback. I hope you agree on this way forward.

Gene, could you please give this a spin.
Attachment #8939903 - Flags: feedback?(gds)
(In reply to Jorg K (GMT+1) from comment #3)
> Another bad choice of reviewer :-(

Somebody needs to give Bugzilla better reviewer choices...
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

f+ for the suite part. Renaming an imap folder with an unread mail in a subfolder fails miserably without the patch in SeaMonkey.

The other part looks ok too. RenameMailboxRespectingSubscriptions returns the return code from LastCommandSuccessful() and it doesn't seem to make sense to first ignore subscribe/unsubsribe errors and then trying to retrieve them later.

Tested with TB 56 and SeaMonkey 2.53. Might be a good candidate for the next ESR 52 release.
Attachment #8939903 - Flags: feedback+
Is there a way to force a failure on this to test the fix? I tried a rename on non-leaf folders and see no problems in tb. (Don't have SeaMonkey.)
(In reply to gene smith from comment #7)
> Is there a way to force a failure on this to test the fix? I tried a rename
> on non-leaf folders and see no problems in tb. (Don't have SeaMonkey.)
Yes, a verbal description of a test case would be nice. Maybe "lock" a file somehow that needs renaming?
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

Review of attachment 8939903 [details] [diff] [review]:
-----------------------------------------------------------------

Apparently this patch really only affects suite/SeaMonkey. I always see renameSucceeded as true regardless of whether it comes directly from the renaming function or from "last command succeeded". Even with the folder.sdb and folder.msf locked with attribute immutable, when renamed, renameSucceeded is set true. It actually creates a new folder, with the new name, with the the same folders and emails below it and leaves the older folder structure in place and tb flags errors when accessed. But the older folders are no longer on the server. When unlocked, the older structure can be deleted in thunderbird and all seems OK.
So this really fixes nothing on Thunderbird that I can see.

::: mailnews/imap/src/nsImapProtocol.cpp
@@ +6817,5 @@
>          newChildName += (currentName + PL_strlen(oldParentMailboxName));
> +        renameSucceeded =
> +          RenameMailboxRespectingSubscriptions(currentName,
> +                                               newChildName.get(),
> +                                               nonHierarchicalRename);

In the comment following this I would suggest changing the xNonHierarchicalRename to exclude the leading 'x' (unless it means something I don't understand). Also, I would move the comment to before the function. 
Also, as I mentioned before, in my simple tests I have only seen renameSucceeded be set true regardless of how it is set. So other than making the code a bit more efficient, this does nothing in thunderbird.
Attachment #8939903 - Flags: feedback?(gds) → feedback+
Thanks, Gene. Neil, how would you like to proceed? Apparently the suite/ hunk fixes the problem for SM. Should we fix the mailnews hunk (comment) as suggested or drop it?
> It [...] leaves the older folder structure in place and tb flags errors when accessed.

Except that the old folders are supposed to be renamed on disk, but that only happens if Thunderbird thinks that the IMAP rename succeeded.

Also, the issue might depend on your IMAP server; I see the problem with Gmail for instance.
Neil, would be be OK with taking the patch and moving the comment up (and losing the x)?
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

OK, let's go with this.
Attachment #8939903 - Flags: review?(Pidgeot18) → review+
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/20758564d6cb
Renaming IMAP folders that have subfolders may fail. r=jorgk,GeneSmith, f=frg
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Assignee: nobody → neil
Target Milestone: --- → Thunderbird 60.0
Assuming it survives a Beta can we take this to ESR52.
Flags: needinfo?(jorgk)
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

Sure.
Flags: needinfo?(jorgk)
Attachment #8939903 - Flags: approval-comm-esr52?
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

That only landed on TB 60 and would ship in TB 52.8 which comes out together with TB 60 ESR.
Attachment #8939903 - Flags: approval-comm-esr52?
Comment on attachment 8939903 [details] [diff] [review]
1428104.diff

Let's reconsider this for the sake of SM which seems to have a benefit from this. It could go into 52.8.
Attachment #8939903 - Flags: approval-comm-esr52?
Attachment #8939903 - Flags: approval-comm-esr52? → approval-comm-esr52+
Summary: Renaming IMAP folders that have subfolders may fail → Renaming IMAP folders that have subfolders may fail (Seamonkey only)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: