From d9e9c849e12e8c253bdd8a4432693768e1acaca3 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 19 Mar 2022 15:49:18 +0000 Subject: [PATCH] imap: do not delete duplicates Currently if user moves the message into some other folder and then moves the message back, the message is considered duplicate even though previous copy was already deleted. This is a common problem reported by users at least twice. Keeping duplicates does no harm except for additional storage usage. If the message is later deleted by the user, all the copies on the server will be deleted. anyway. --- CHANGELOG.md | 2 ++ src/imap.rs | 21 +-------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45d4c3006..c2c43b2d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - do not delete messages without Message-IDs as duplicates #3095 - Assign replies from a different email address to the correct chat #3119 - start ephemeral timer when seen status is synchronized via IMAP #3122 +- do not delete duplicate messages on IMAP immediately to accidentally deleting + the last copy #3138 ### Changes - add more SMTP logging #3093 diff --git a/src/imap.rs b/src/imap.rs index 4081a5dd4..4dbca3eae 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -713,19 +713,6 @@ impl Imap { None => folder.to_string(), }; - let duplicate = context - .sql - .count( - "SELECT COUNT(*) - FROM imap - WHERE rfc724_mid=? - AND folder=? - AND uid 0; - context .sql .execute( @@ -734,13 +721,7 @@ impl Imap { ON CONFLICT(folder, uid, uidvalidity) DO UPDATE SET rfc724_mid=excluded.rfc724_mid, target=excluded.target", - paramsv![ - message_id, - folder, - uid, - uid_validity, - if duplicate { "" } else { &target } - ], + paramsv![message_id, folder, uid, uid_validity, &target], ) .await?;