Added POP3 quick check

pull/200/head
M66B 3 years ago
parent 7186d57c46
commit 2b746c0a5e

File diff suppressed because it is too large Load Diff

@ -2299,12 +2299,33 @@ class Core {
? imessages.length ? imessages.length
: Math.min(imessages.length, account.max_messages)); : Math.min(imessages.length, account.max_messages));
boolean sync = true;
if (imessages.length > 0 && folder.last_sync_count != null &&
imessages.length == folder.last_sync_count) {
// Check if last message known as new messages indicator
MessageHelper helper = new MessageHelper((MimeMessage) imessages[imessages.length - 1], context);
String msgid = helper.getMessageID();
if (msgid != null) {
int count = db.message().countMessageByMsgId(folder.id, msgid);
if (count == 1) {
Log.i(account.name + " POP having last msgid=" + msgid);
sync = false;
}
}
}
EntityLog.log(context, account.name + " POP" + EntityLog.log(context, account.name + " POP" +
" device=" + ids.size() + " device=" + ids.size() +
" server=" + imessages.length + " server=" + imessages.length +
" max=" + max + "/" + account.max_messages + " max=" + max + "/" + account.max_messages +
" last=" + folder.last_sync_count +
" sync=" + sync +
" uidl=" + hasUidl); " uidl=" + hasUidl);
folder.last_sync_count = imessages.length;
db.folder().setFolderLastSyncCount(folder.id, folder.last_sync_count);
if (sync) {
// Index IDs // Index IDs
Map<String, String> uidlMsgId = new HashMap<>(); Map<String, String> uidlMsgId = new HashMap<>();
for (TupleUidl id : ids) { for (TupleUidl id : ids) {
@ -2550,6 +2571,7 @@ class Core {
((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, account.name + " POP done"); EntityLog.log(context, account.name + " POP done");

@ -65,7 +65,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 202, version = 203,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -2052,6 +2052,12 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion); Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("UPDATE identity SET use_ip = 0 WHERE host = 'smtp.office365.com'"); db.execSQL("UPDATE identity SET use_ip = 0 WHERE host = 'smtp.office365.com'");
} }
}).addMigrations(new Migration(202, 203) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `folder` ADD COLUMN `last_sync_count` INTEGER");
}
}).addMigrations(new Migration(998, 999) { }).addMigrations(new Migration(998, 999) {
@Override @Override
public void migrate(@NonNull SupportSQLiteDatabase db) { public void migrate(@NonNull SupportSQLiteDatabase db) {

@ -353,6 +353,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET last_sync = :last_sync WHERE id = :id AND NOT (last_sync IS :last_sync)") @Query("UPDATE folder SET last_sync = :last_sync WHERE id = :id AND NOT (last_sync IS :last_sync)")
int setFolderLastSync(long id, long last_sync); int setFolderLastSync(long id, long last_sync);
@Query("UPDATE folder SET last_sync_count = :last_sync_count WHERE id = :id AND NOT (last_sync_count IS :last_sync_count)")
int setFolderLastSyncCount(long id, Integer last_sync_count);
@Query("UPDATE folder SET read_only = :read_only WHERE id = :id AND NOT (read_only IS :read_only)") @Query("UPDATE folder SET read_only = :read_only WHERE id = :id AND NOT (read_only IS :read_only)")
int setFolderReadOnly(long id, boolean read_only); int setFolderReadOnly(long id, boolean read_only);

@ -136,6 +136,7 @@ public class EntityFolder extends EntityOrder implements Serializable {
public Boolean inferiors = true; public Boolean inferiors = true;
public String error; public String error;
public Long last_sync; public Long last_sync;
public Integer last_sync_count; // POP3
static final String INBOX = "Inbox"; static final String INBOX = "Inbox";
static final String OUTBOX = "Outbox"; static final String OUTBOX = "Outbox";

Loading…
Cancel
Save