POP3: lookahead headers

pull/199/head
M66B 4 years ago
parent e5474bd27f
commit 9dc426b9fb

@ -2254,11 +2254,11 @@ class Core {
EntityLog.log(context, folder.name + " POP capabilities= " + caps.keySet()); EntityLog.log(context, folder.name + " POP capabilities= " + caps.keySet());
Message[] imessages = ifolder.getMessages(); Message[] imessages = ifolder.getMessages();
EntityLog.log(context, folder.name + " POP messages=" + imessages.length); int max = (account.max_messages == null ? imessages.length : Math.max(account.max_messages * 2, 100));
EntityLog.log(context, folder.name + " POP messages=" + imessages.length +
if (account.max_messages != null && imessages.length > account.max_messages) " max=" + max + "/" + account.max_messages);
imessages = Arrays.copyOfRange(imessages, if (imessages.length > max)
imessages.length - account.max_messages, imessages.length); imessages = Arrays.copyOfRange(imessages, imessages.length - max, imessages.length);
boolean hasUidl = caps.containsKey("UIDL"); boolean hasUidl = caps.containsKey("UIDL");
if (hasUidl) { if (hasUidl) {
@ -2315,7 +2315,13 @@ class Core {
} }
} }
for (Message imessage : imessages) for (int i = 0; i < imessages.length; i++) {
if (account.max_messages != null && i >= account.max_messages) {
EntityLog.log(context, folder.name + " POP reached max=" + account.max_messages);
break;
}
Message imessage = imessages[i];
try { try {
if (!state.isRunning()) if (!state.isRunning())
return; return;
@ -2504,6 +2510,7 @@ class Core {
} finally { } finally {
((POP3Message) imessage).invalidate(true); ((POP3Message) imessage).invalidate(true);
} }
}
db.folder().setFolderLastSync(folder.id, new Date().getTime()); db.folder().setFolderLastSync(folder.id, new Date().getTime());
EntityLog.log(context, folder.name + " POP done"); EntityLog.log(context, folder.name + " POP done");

Loading…
Cancel
Save