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
This commit is contained in:
Daniel Volk 2014-03-06 15:19:36 +01:00 committed by Steve Kondik
parent a7d1b42409
commit c2c258f261

View File

@ -557,7 +557,8 @@ class ImapFolder extends Folder {
public Message[] getMessages(long startDate, long endDate, MessageRetrievalListener listener) public Message[] getMessages(long startDate, long endDate, MessageRetrievalListener listener)
throws MessagingException { throws MessagingException {
String [] uids = null; 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()); LogUtils.d(Logging.LOG_TAG, "getMessages dateRange " + command.toString());
try { try {
@ -570,7 +571,8 @@ class ImapFolder extends Folder {
// See b/11183568 // See b/11183568
LogUtils.d(Logging.LOG_TAG, e, "query failed %s, trying alternate", LogUtils.d(Logging.LOG_TAG, e, "query failed %s, trying alternate",
command.toString()); command.toString());
command = generateDateRangeCommand(startDate, endDate, true); command = generateDateRangeCommand(startDate, endDate, true)
+ " NOT DELETED";
try { try {
uids = searchForUids(command, true); uids = searchForUids(command, true);
} catch (ImapException e2) { } catch (ImapException e2) {