|
|
@ -3289,45 +3289,51 @@ class Core {
|
|
|
|
ifolder.fetch(imessages, ifetch);
|
|
|
|
ifolder.fetch(imessages, ifetch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!account.leave_on_device) {
|
|
|
|
long now = new Date().getTime();
|
|
|
|
if (hasUidl) {
|
|
|
|
|
|
|
|
Map<String, TupleUidl> known = new HashMap<>();
|
|
|
|
|
|
|
|
for (TupleUidl id : ids)
|
|
|
|
|
|
|
|
if (id.uidl != null)
|
|
|
|
|
|
|
|
known.put(id.uidl, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Message imessage : imessages) {
|
|
|
|
|
|
|
|
String uidl = ifolder.getUID(imessage);
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(uidl))
|
|
|
|
|
|
|
|
known.clear(); // better safe than sorry
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
known.remove(uidl);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (TupleUidl uidl : known.values())
|
|
|
|
if (hasUidl) {
|
|
|
|
if (!uidl.ui_flagged) {
|
|
|
|
Map<String, TupleUidl> known = new HashMap<>();
|
|
|
|
EntityLog.log(context, account.name + " POP purging uidl=" + uidl.uidl);
|
|
|
|
for (TupleUidl id : ids)
|
|
|
|
db.message().deleteMessage(uidl.id);
|
|
|
|
if (id.uidl != null)
|
|
|
|
}
|
|
|
|
known.put(id.uidl, id);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Map<String, TupleUidl> known = new HashMap<>();
|
|
|
|
for (Message imessage : imessages) {
|
|
|
|
for (TupleUidl id : ids)
|
|
|
|
String uidl = ifolder.getUID(imessage);
|
|
|
|
if (id.msgid != null)
|
|
|
|
if (TextUtils.isEmpty(uidl))
|
|
|
|
known.put(id.msgid, id);
|
|
|
|
known.clear(); // better safe than sorry
|
|
|
|
|
|
|
|
else
|
|
|
|
for (int i = imessages.length - max; i < imessages.length; i++) {
|
|
|
|
known.remove(uidl);
|
|
|
|
Message imessage = imessages[i];
|
|
|
|
}
|
|
|
|
MessageHelper helper = new MessageHelper((MimeMessage) imessage, context);
|
|
|
|
|
|
|
|
String msgid = helper.getPOP3MessageID(); // expensive!
|
|
|
|
for (TupleUidl uidl : known.values())
|
|
|
|
known.remove(msgid);
|
|
|
|
if (!uidl.ui_flagged &&
|
|
|
|
|
|
|
|
(!account.leave_on_device ||
|
|
|
|
|
|
|
|
(uidl.ui_hide && (uidl.ui_busy == null || uidl.ui_busy < now)))) {
|
|
|
|
|
|
|
|
EntityLog.log(context, account.name + " POP purging" +
|
|
|
|
|
|
|
|
" uidl=" + uidl.uidl + " hidden=" + uidl.ui_hide);
|
|
|
|
|
|
|
|
db.message().deleteMessage(uidl.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Map<String, TupleUidl> known = new HashMap<>();
|
|
|
|
|
|
|
|
for (TupleUidl id : ids)
|
|
|
|
|
|
|
|
if (id.msgid != null)
|
|
|
|
|
|
|
|
known.put(id.msgid, id);
|
|
|
|
|
|
|
|
|
|
|
|
for (TupleUidl uidl : known.values())
|
|
|
|
for (int i = imessages.length - max; i < imessages.length; i++) {
|
|
|
|
if (!uidl.ui_flagged) {
|
|
|
|
Message imessage = imessages[i];
|
|
|
|
EntityLog.log(context, account.name + " POP purging msgid=" + uidl.msgid);
|
|
|
|
MessageHelper helper = new MessageHelper((MimeMessage) imessage, context);
|
|
|
|
db.message().deleteMessage(uidl.id);
|
|
|
|
String msgid = helper.getPOP3MessageID(); // expensive!
|
|
|
|
}
|
|
|
|
known.remove(msgid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (TupleUidl uidl : known.values())
|
|
|
|
|
|
|
|
if (!uidl.ui_flagged &&
|
|
|
|
|
|
|
|
(!account.leave_on_device ||
|
|
|
|
|
|
|
|
(uidl.ui_hide && (uidl.ui_busy == null || uidl.ui_busy < now)))) {
|
|
|
|
|
|
|
|
EntityLog.log(context, account.name + " POP purging" +
|
|
|
|
|
|
|
|
" msgid=" + uidl.msgid + " hidden=" + uidl.ui_hide);
|
|
|
|
|
|
|
|
db.message().deleteMessage(uidl.id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean _new = true;
|
|
|
|
boolean _new = true;
|
|
|
|