Skip to content

refactor: Remove code that moves messages between IMAP folders - #8734

Merged
Hocuri merged 2 commits into
mainfrom
hoc/remove-imap-moving-code
Sep 22, 2026
Merged

Hocuri merged 2 commits into
mainfrom
hoc/remove-imap-moving-code

Conversation

@Hocuri

@Hocuri Hocuri commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #8456

This PR removes code that was needed for moving messages between IMAP folders. We haven't been moving messages since a long time already, so, this code was dead.

I also added a second commit that removes the unused ImapMessageMoved event.

What this PR does NOT yet do:

  • Refactor delete_messages - The code there could be slightly simplified, but then we need to be very careful not to introduce a bug that wrongly deletes messages
  • Remove the repeated calls to select_folder() / select_with_uidvalidity() - can be done in a follow-up

@Hocuri
Hocuri requested a review from link2xt September 22, 2026 12:20
@Hocuri
Hocuri force-pushed the hoc/remove-imap-moving-code branch from 96edf00 to c8a6b61 Compare September 22, 2026 12:37
Comment thread src/imap.rs
// message, move it to the movebox and then download the second message before
// downloading the first one, if downloading from inbox before moving is allowed.
if folder == target
if !delete

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add debug_assert!(delete || folder == target) so it crashes in tests if we somehow set target to something other than folder.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few lines above we have let target = if delete { "" } else { folder };, but I'll add this debug_assert to delete_messages()

Comment thread src/imap.rs
for (target, rowid_set, uid_set) in UidGrouper::from(rows) {
// Select folder inside the loop to avoid selecting it if there are no pending
// MOVE/DELETE operations. This does not result in multiple SELECT commands
// DELETE operations. This does not result in multiple SELECT commands

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably simplified in a follow-up as well, comment is outdated because we never select any folder other than INBOX (or whatever is configured in imap_folder which then acts as an inbox). We can select the folder right after login and then be sure we never unselect it.

@Hocuri
Hocuri force-pushed the hoc/remove-imap-moving-code branch from c8a6b61 to 051f96b Compare September 22, 2026 12:52
@Hocuri
Hocuri merged commit 2a5058a into main Sep 22, 2026
30 checks passed
@Hocuri
Hocuri deleted the hoc/remove-imap-moving-code branch September 22, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants