mirror of https://github.com/M66B/FairEmail.git
Improved POP3 sync
This commit is contained in:
parent
600b114a29
commit
629e1b0e1f
|
@ -1532,35 +1532,15 @@ class Core {
|
|||
List<String> existing = db.message().getMsgIds(folder.id);
|
||||
Log.i(folder.name + " POP existing=" + existing.size());
|
||||
|
||||
int count = 0;
|
||||
for (Message imessage : imessages)
|
||||
try {
|
||||
if (!state.isRunning())
|
||||
return;
|
||||
|
||||
MessageHelper helper = new MessageHelper((MimeMessage) imessage);
|
||||
|
||||
String msgid;
|
||||
if (caps.containsKey("UIDL")) {
|
||||
String uid = ifolder.getUID(imessage);
|
||||
if (existing.contains(uid))
|
||||
msgid = uid;
|
||||
else {
|
||||
msgid = helper.getMessageID();
|
||||
if (existing.contains(msgid)) {
|
||||
List<EntityMessage> messages = db.message().getMessagesByMsgId(account.id, msgid);
|
||||
if (messages.size() == 1) {
|
||||
messages.get(0).msgid = uid;
|
||||
db.message().updateMessage(messages.get(0));
|
||||
existing.remove(msgid);
|
||||
existing.add(uid);
|
||||
msgid = uid;
|
||||
Log.w(folder.name + " POP update uid=" + uid + " msgid=" + msgid);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
msgid = helper.getMessageID();
|
||||
String msgid = caps.containsKey("UIDL")
|
||||
? ifolder.getUID(imessage)
|
||||
: helper.getMessageID();
|
||||
|
||||
if (TextUtils.isEmpty(msgid)) {
|
||||
Log.w(folder.name + " POP no message ID");
|
||||
|
@ -1573,6 +1553,7 @@ class Core {
|
|||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
Log.i(folder.name + " POP sync=" + msgid);
|
||||
|
||||
Long sent = helper.getSent();
|
||||
|
@ -1684,6 +1665,7 @@ class Core {
|
|||
updateContactInfo(context, folder, message);
|
||||
} catch (Throwable ex) {
|
||||
db.folder().setFolderError(folder.id, Log.formatThrowable(ex));
|
||||
}
|
||||
} finally {
|
||||
((POP3Message) imessage).invalidate(true);
|
||||
}
|
||||
|
@ -1694,7 +1676,7 @@ class Core {
|
|||
db.message().deleteMessage(folder.id, msgid);
|
||||
}
|
||||
|
||||
Log.i(folder.name + " done");
|
||||
Log.i(folder.name + " POP done");
|
||||
} finally {
|
||||
db.folder().setFolderSyncState(folder.id, null);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue