Added POP3 delete fail-safe

This commit is contained in:
M66B 2023-09-03 08:00:34 +02:00
parent 3f7590ac87
commit 74cfeaa25a
2 changed files with 6 additions and 3 deletions

View File

@ -160,6 +160,7 @@ class Core {
private static final long EXISTS_RETRY_DELAY = 20 * 1000L; // milliseconds
private static final int FIND_RETRY_COUNT = 3; // times
private static final long FIND_RETRY_DELAY = 5 * 1000L; // milliseconds
private static final long POP3_KEEP_DELETED = 3 * 24 * 3600 * 1000L; // milliseconds
private static final Map<Long, List<EntityIdentity>> accountIdentities = new HashMap<>();
@ -3645,7 +3646,8 @@ class Core {
if (account.max_messages != null && !account.leave_on_device) {
int hidden = db.message().setMessagesUiHide(folder.id, Math.abs(account.max_messages));
int deleted = db.message().deleteMessagesKeep(folder.id, Math.abs(account.max_messages) + 100);
int deleted = db.message().deleteMessagesKeep(folder.id,
Math.abs(account.max_messages) + 100, new Date().getTime() - POP3_KEEP_DELETED);
EntityLog.log(context, account.name + " POP" +
" cleanup max=" + account.max_messages +
" hidden=" + hidden +

View File

@ -1008,7 +1008,7 @@ public interface DaoMessage {
" AND (ui_seen OR :unseen)" +
" AND NOT ui_flagged" +
" AND stored < :sync_time" + // moved, browsed
" AND (ui_snoozed IS NULL OR ui_snoozed =" + Long.MAX_VALUE+")")
" AND (ui_snoozed IS NULL OR ui_snoozed =" + Long.MAX_VALUE + ")")
List<Long> getMessagesBefore(long folder, long sync_time, long keep_time, boolean unseen);
@Query("DELETE FROM message" +
@ -1028,7 +1028,8 @@ public interface DaoMessage {
" AND id NOT IN (" +
" SELECT id FROM message" +
" WHERE folder = :folder" +
" AND stored < :before" +
" ORDER BY received DESC" +
" LIMIT :keep)")
int deleteMessagesKeep(long folder, int keep);
int deleteMessagesKeep(long folder, int keep, long before);
}