imap: do not unnecessarily SELECT folder in move_delete_messages()

If there are no MOVE/DELETE operations pending, the folder
should not be SELECTed.

When `only_fetch_mvbox` is enabled, `fetch_new_messages` skips
most folders, but `move_delete_messages` always selects the
folder even if there are no operations pending. Selecting
all folders wastes time during folder scan and turns
recent messages into non-recent.
This commit is contained in:
link2xt
2022-05-21 13:31:29 +00:00
parent d06683489f
commit deece15648
2 changed files with 13 additions and 1 deletions

View File

@@ -1,5 +1,12 @@
# Changelog
## Unreleased
### Fixes
- do not unnecessarily SELECT folders if there are no operations planned on
them #3333
## 1.83.0
### Fixes

View File

@@ -1030,9 +1030,14 @@ impl Imap {
.await?;
self.prepare(context).await?;
self.select_folder(context, Some(folder)).await?;
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
// being sent because `select_folder()` does nothing if the folder is already
// selected.
self.select_folder(context, Some(folder)).await?;
// Empty target folder name means messages should be deleted.
if target.is_empty() {
self.delete_message_batch(context, &uid_set, rowid_set)