From c2c258f2612272fe68583c39ac60067a389b3f31 Mon Sep 17 00:00:00 2001 From: Daniel Volk Date: Thu, 6 Mar 2014 15:19:36 +0100 Subject: [PATCH] Don't fetch deleted messages from IMAP folder Fetching messages from an IMAP folder within a specific date range returns messages marked as deleted, also. Unlike every other getMessages() method, which filter out deleted messages. This leaves server deleted messages untouched in the mail conversation view, even when the folder is synced manually. This patch adds "NOT DELETED" to the IMAP search command, when searching for mails in a given date range. Change-Id: I49e4adfcab9a1de1d1baa4700462a82df651f3cb --- provider_src/com/android/email/mail/store/ImapFolder.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/provider_src/com/android/email/mail/store/ImapFolder.java b/provider_src/com/android/email/mail/store/ImapFolder.java index 3a9081131..2eefdfec3 100644 --- a/provider_src/com/android/email/mail/store/ImapFolder.java +++ b/provider_src/com/android/email/mail/store/ImapFolder.java @@ -557,7 +557,8 @@ class ImapFolder extends Folder { public Message[] getMessages(long startDate, long endDate, MessageRetrievalListener listener) throws MessagingException { String [] uids = null; - String command = generateDateRangeCommand(startDate, endDate, false); + String command = generateDateRangeCommand(startDate, endDate, false) + + " NOT DELETED"; LogUtils.d(Logging.LOG_TAG, "getMessages dateRange " + command.toString()); try { @@ -570,7 +571,8 @@ class ImapFolder extends Folder { // See b/11183568 LogUtils.d(Logging.LOG_TAG, e, "query failed %s, trying alternate", command.toString()); - command = generateDateRangeCommand(startDate, endDate, true); + command = generateDateRangeCommand(startDate, endDate, true) + + " NOT DELETED"; try { uids = searchForUids(command, true); } catch (ImapException e2) {