Simplification

pull/216/head
M66B 3 months ago
parent 3785bc50a7
commit 8d3d16b0ec

@ -3953,7 +3953,8 @@ class Core {
// Delete old local messages
long delete_time = new Date().getTime() - 3600 * 1000L;
if (auto_delete) {
List<Long> tbds = db.message().getMessagesBefore(folder.id, delete_time, keep_time, keep_unread_time, delete_unseen);
List<Long> tbds = db.message().getMessagesBefore(folder.id, delete_time, keep_time,
!delete_unseen || sync_unseen ? 0 : keep_unread_time);
Log.i(folder.name + " local tbd=" + tbds.size());
EntityFolder trash = db.folder().getFolderByType(folder.account, EntityFolder.TRASH);
for (Long tbd : tbds) {
@ -3967,7 +3968,7 @@ class Core {
}
} else {
int old = db.message().deleteMessagesBefore(folder.id, delete_time, keep_time,
sync_unseen ? 0 : keep_unread_time, delete_unseen && !sync_unseen);
!delete_unseen || sync_unseen ? 0 : keep_unread_time);
Log.i(folder.name + " local old=" + old);
}

@ -1043,21 +1043,21 @@ public interface DaoMessage {
" WHERE folder = :folder" +
" AND received < :keep_time" +
" AND NOT uid IS NULL" +
" AND (ui_seen OR received < :keep_unread_time OR :unseen)" +
" AND (ui_seen OR received < :keep_unread_time)" +
" AND NOT ui_flagged" +
" AND stored < :sync_time" + // moved, browsed
" AND (ui_snoozed IS NULL OR ui_snoozed =" + Long.MAX_VALUE + ")")
List<Long> getMessagesBefore(long folder, long sync_time, long keep_time, long keep_unread_time, boolean unseen);
List<Long> getMessagesBefore(long folder, long sync_time, long keep_time, long keep_unread_time);
@Query("DELETE FROM message" +
" WHERE folder = :folder" +
" AND received < :keep_time" +
" AND NOT uid IS NULL" +
" AND (ui_seen OR received < :keep_unread_time OR :unseen)" +
" AND (ui_seen OR received < :keep_unread_time)" +
" AND NOT ui_flagged" +
" AND stored < :sync_time" + // moved, browsed
" AND (ui_snoozed IS NULL OR ui_snoozed = " + Long.MAX_VALUE + ")")
int deleteMessagesBefore(long folder, long sync_time, long keep_time, long keep_unread_time, boolean unseen);
int deleteMessagesBefore(long folder, long sync_time, long keep_time, long keep_unread_time);
@Transaction
@Query("DELETE FROM message" +

Loading…
Cancel
Save