Repository navigation
#2036: a run cut off after the server made a folder no longer leaves it here twice - #2251
Conversation
…leaves it here twice A run hands over the folder list as a piece of its own before its push, and the app takes that piece in first. After a run that made a mailbox for a folder made here and was cut off before its answer was kept, adopt_listed gave that mailbox a new folder of its own: the server's copies of the mail came down into it (here twice), and the push's `created` for the waiting folder was refused, so that folder failed at every run with "it has another folder of that name". The piece with the list now also says, as `created`, which folders here wait for a mailbox it lists (push::already_made): the moves and places of the request into ordinary folders made here, worked out as the push does (name_below, already_there, the personal namespace), nothing asked of the server; the push takes them as its destinations and doesn't say them again. The engine takes `created` in before the list, so the waiting folder follows the mailbox and no new folder is made for it. A server may also list the levels above such a mailbox as mailboxes of their own (RFC 3501, 6.3.3). adopt_listed gives such a level to the parent made here it stands for, only where the trees agree all the way up: each level's last part is the parent's name as the push makes it, by the delimiter the list shows; each parent follows nothing and holds no mail but what waits to go up; the walk ends at a level the parent's own parent follows, or at the top of both. Folder moves here aren't made on the server, so the trees can differ: then nothing is tied, and a level two parents would stand for is tied to neither. Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
vangel76
left a comment
There was a problem hiding this comment.
Checked IMAP path and namespace calculation, LIST-first and whole-result apply, account folder roles, pending moves and placements, parent adoption, and the synthetic recovery tests against current main.
Source review only. I did not build the project, run tests, or check CI.
| // And, in the same piece, the folders here that wait for a mailbox it lists (made by a run | ||
| // whose answer was never kept, #2036): taken in before the list, so that the list doesn't | ||
| // give that mailbox a new folder of its own. | ||
| let made = crate::push::already_made(request, &mailboxes, personal.as_ref()); |
There was a problem hiding this comment.
P2. Preserve the server's standard folder when adopting a listed destination
If a local IMAP folder called Spam has a message waiting to upload and the server LIST identifies Spam as the account's Junk mailbox, already_made sees the raw name and claims it for the custom folder before adopt_listed runs. The normal LIST path would link the account's Junk Email folder to that mailbox. Instead, the existing-remote branch leaves Spam custom and Junk Email unlinked, so the server's spam appears in an ordinary folder and future listings keep finding the name already claimed. Use the classified LIST plan for early adoption and leave server-designated standard folders to the standard-folder mapping. Add a piece-by-piece test with a pending placement into a custom Spam and a listed Spam carrying \Junk.
benandez
left a comment
There was a problem hiding this comment.
Approve. Two independent reads found no path to mail loss, duplicate mail or a folder tied to the wrong mailbox. Ties are by name, only onto folders that follow nothing; the engine's free check still guards created; the parent rule matches level by level and stops at MAX_LEVELS; and created is taken in before listed, so a run cut off after the listing piece leaves a correct tie.
Non-blocking:
push.rs:147-148and the PR body say a mailbox two waiting folders would both be made as "is left to the push, which says so", butalready_thereonly checks the request's own snapshot, so the push says nothing unless its own CREATE fails. Fix the comment, or add a check.- A same-named mailbox another program made meanwhile is now adopted (mail goes both ways, nothing lost). That matches the push's stated intent, but a test pinning it would help.
already_madebuilds its ownPushliteral; a sharedPush::newwould keep it from drifting frompush().
…tays the Junk folder's After UCSLabs#2251's review. A mailbox that two waiting folders would both be made as is the first one's, in the order the push takes them, and the push tells the other. A mailbox the server flags for a standard job is the standard folder's, unless it holds the waiting folder's own mail, put there by a run that was cut off: a move into a folder that only exists here now carries the message's Message-ID, so it can be looked for there. One Push::new for push() and already_made. Human-reviewed, AI-assisted, nobody's mailbox harmed.
UCSLabs#2036: one waiting folder per mailbox, and the server's junk stays the Junk folder's (UCSLabs#2251 follow-ups)



Part of #2036: the main case. The "Related" case in the issue (a mailbox the server never lists, so CREATE answers that it exists) is left open.
What changes for the person using MailCraft
Moving mail into a folder made only on this computer makes that folder on the IMAP server. Suppose the Send/Receive that made it was cut off before its answer was kept (the program closed). The next Send/Receive then made a second folder for the server's mailbox ("Acme (2)", or "Clients.Acme" at the top as reported) and brought the mail down into it. The mail was then here twice. The folder it had been moved into stayed waiting: its mail never got a server copy of its own, and anything moved there afterwards failed at every run with "it has another folder of that name".
Now the next Send/Receive ties the waiting folder to the mailbox the cut-off run made. The mail is here once, and what is moved there afterwards goes up.
A folder that an earlier version already made twice stays as it is. Putting two folders back together is a decision of its own, and the release note says so.
Changes a default: no
How it works
A run hands over the folder list as a piece of its own before it pushes anything (
crates/net/src/sync.rs), and the app takes that piece in first.adopt_listedgave every listed mailbox without a folder here a new folder. When the push then adopted the mailbox for the waiting folder, the engine refused itscreated, because another folder followed the mailbox by then.The piece with the list now also says, as
created, which folders here wait for a mailbox it lists. That ispush::already_made, incrates/net/src/push.rs:name_belowandalready_thereand the personal namespace fromNAMESPACE(cPanel's and Courier'sINBOX.). Nothing is asked of the server.take_in_newstakescreatedin beforelisted, so the waiting folder follows the mailbox before the list could give it a new folder.AlreadyMade). The push then neither works them out again nor reportscreateda second time.A server may also list the levels above such a mailbox as mailboxes of their own (RFC 3501, 6.3.3 says it should make them). A large import hits this without any run being cut off: a run carries at most
MAX_PLACESmessages, so a parent's own mail can still be waiting when the level is listed.adopt_listednow gives such a level to the parent made here that it stands for, instead of a new folder (above, incrates/engine/src/cmd/account.rs). It does so only where the two trees agree all the way up:made_level, mirroringname_below), using the delimiter the list itself shows between the level and the one above.Folder moves here aren't made on the server, so the trees can differ. Then nothing is tied, and a level two parents would stand for is tied to neither. Nothing about the server's delimiter or prefix is guessed.
This went through two rounds of adversarial review before I opened it:
INBOX.servers and names that hold the delimiter, and could tie a folder called "shared" to the level that holds other users' folders. Working the mailboxes out where the push works them out (already_made) avoids all three.Not covered:
INBOX.Clients): the trees don't line up, as the engine isn't told the prefix, so that level still gets a new folder. The waiting folder below it is tied all the same.v1.0andv1_0on a.server) are left to the push, which says so, as now.How it was checked
New
apps/mailcraft-cli/tests/folders_a_lost_run_made.rs, 14 tests against the fake IMAP server. Each run is taken in pieces, as the app does (sync_with+apply_sync_part), mostly after a run cut off once the server made the folder:INBOX/Clients, and no folder is made beside it;.(Clients.Acme);INBOX.Acme);J. Smith, madeJ_ Smith);Pending::Move), not only placed from elsewhere;INBOX/Clients): "Clients" is tied, and mail moved into it afterwards goes up;INBOX/Clients,INBOX/Clients/Sub) are tied all the way up;Work); a child moved under a new parent ("Old" is notClients);On
main, 10 of them fail. The 4 guards pass both ways (the "shared", "Projects", "Old" and whole-run tests).The existing
moves_between_accountsend-to-end tests and all 1,038mailcraft-nettests pass.macOS 26.6 (Apple silicon), Rust 1.98.1:
cargo xtask cipasses all 15 steps with #2189: clippy passes on macOS: pin_for is used on Linux and FreeBSD alone #2190'spin_forfix applied locally. Without it, clippy stops on macOS (cargo xtask cifails at clippy on macOS:pin_foris never used #2189). This branch doesn't include that fix.Not built on Windows or Linux.
cargo xtask cipassesA crash or data-loss fix has its regression test
"Allow edits by maintainers": the fork belongs to an organisation, where GitHub doesn't offer that box. If you'd like to push to this branch, say so and you'll have write access to
easier-digital/mailcraft.I have signed the CLA, or will by commenting on this pull request
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Summary by CodeRabbit