mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user