Check delete flag on sync

This commit is contained in:
M66B 2019-08-24 09:38:11 +02:00
parent a4e8f8fb3c
commit 0ff2c5a45d
1 changed files with 6 additions and 3 deletions

View File

@ -44,6 +44,7 @@ import com.sun.mail.iap.Response;
import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.imap.IMAPStore;
import com.sun.mail.imap.protocol.FLAGS;
import com.sun.mail.imap.protocol.FetchResponse;
import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.imap.protocol.UID;
@ -1115,7 +1116,8 @@ class Core {
for (int i = 0; i < imessages.length && state.isRunning() && state.isRecoverable(); i++)
try {
uids.remove(ifolder.getUID(imessages[i]));
if (!imessages[i].isSet(Flags.Flag.DELETED))
uids.remove(ifolder.getUID(imessages[i]));
} catch (MessageRemovedException ex) {
Log.w(folder.name, ex);
} catch (Throwable ex) {
@ -1165,14 +1167,15 @@ class Core {
else
sb.append(range.first).append(':').append(range.second);
}
Response[] responses = protocol.command("UID FETCH " + sb + " (UID)", null);
Response[] responses = protocol.command("UID FETCH " + sb + " (UID FLAGS)", null);
if (responses.length > 0 && responses[responses.length - 1].isOK()) {
for (Response response : responses)
if (response instanceof FetchResponse) {
FetchResponse fr = (FetchResponse) response;
UID uid = fr.getItem(UID.class);
if (uid != null)
FLAGS flags = fr.getItem(FLAGS.class);
if (uid != null && (flags == null || !flags.contains(Flags.Flag.DELETED)))
uids.remove(uid.uid);
}
} else {