Remove LocalFolder.purgeToVisibleLimit()

The method was only called at the end of a mailbox sync. But during sync
another mechanism already destroyed messages outside of the sync window.
This commit is contained in:
cketti 2019-12-01 14:21:28 +01:00
parent 6b91f6085a
commit b1faba725f
6 changed files with 0 additions and 81 deletions

View file

@ -8,7 +8,6 @@ import com.fsck.k9.Account
import com.fsck.k9.Preferences
import com.fsck.k9.backend.api.BackendFolder
import com.fsck.k9.backend.api.BackendFolder.MoreMessages
import com.fsck.k9.backend.api.MessageRemovalListener
import com.fsck.k9.mail.Flag
import com.fsck.k9.mail.Message
import java.util.Date
@ -116,11 +115,6 @@ class K9BackendFolder(
return database.setString(column = "push_state", value = pushState)
}
// TODO: Move implementation from LocalFolder to this class
override fun purgeToVisibleLimit(listener: MessageRemovalListener) {
localFolder.purgeToVisibleLimit(listener)
}
override fun isMessagePresent(messageServerId: String): Boolean {
return database.execute(false) { db ->
val cursor = db.query("messages", arrayOf("id"), "uid = ?", arrayOf(messageServerId), null, null, null)

View file

@ -445,47 +445,6 @@ public class LocalFolder extends Folder<LocalMessage> {
return visibleLimit;
}
public void purgeToVisibleLimit(final MessageRemovalListener listener) throws MessagingException {
// don't purge messages while a Search is active since it might throw away search results
if (searchStatusManager.isActive()) {
return;
}
if (visibleLimit == 0) {
return;
}
open(OPEN_MODE_RW);
localStore.getDatabase().execute(false, new DbCallback<Void>() {
@Override
public Void doDbWork(final SQLiteDatabase db) {
Cursor cursor = db.rawQuery("SELECT uid " +
"FROM messages " +
"WHERE empty = 0 AND deleted = 0 AND folder_id = ? ORDER BY date DESC " +
" LIMIT -1 OFFSET ?",
new String[] { Long.toString(getDatabaseId()), Integer.toString(visibleLimit) });
try {
while (cursor.moveToNext()) {
String uid = cursor.getString(0);
LocalMessage localMessage = getMessage(uid);
if (listener != null) {
listener.messageRemoved(localMessage);
}
destroyMessage(localMessage);
}
} catch (Exception e) {
Timber.d(e, "Got an exception");
} finally {
Utility.closeQuietly(cursor);
}
return null;
}
});
}
public void setVisibleLimit(final int visibleLimit) throws MessagingException {
updateMoreMessagesOnVisibleLimitChange(visibleLimit, this.visibleLimit);

View file

@ -19,7 +19,6 @@ interface BackendFolder {
fun setStatus(status: String?)
fun getPushState(): String?
fun setPushState(pushState: String?)
fun purgeToVisibleLimit(listener: MessageRemovalListener)
fun isMessagePresent(messageServerId: String): Boolean
fun getMessageFlags(messageServerId: String): Set<Flag>
fun setMessageFlag(messageServerId: String, flag: Flag, value: Boolean)

View file

@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.fsck.k9.backend.api.BackendFolder;
import com.fsck.k9.backend.api.BackendFolder.MoreMessages;
import com.fsck.k9.backend.api.BackendStorage;
import com.fsck.k9.backend.api.MessageRemovalListener;
import com.fsck.k9.backend.api.SyncConfig;
import com.fsck.k9.backend.api.SyncConfig.ExpungePolicy;
import com.fsck.k9.backend.api.SyncListener;
@ -394,16 +393,6 @@ class ImapSync {
Timber.d("SYNC: Synced remote messages for folder %s, %d new messages", folder, newMessages.get());
if (purgeToVisibleLimit) {
backendFolder.purgeToVisibleLimit(new MessageRemovalListener() {
@Override
public void messageRemoved(Message message) {
listener.syncRemovedMessage(folder, message.getUid());
}
});
}
return newMessages.get();
}

View file

@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.fsck.k9.backend.api.BackendFolder;
import com.fsck.k9.backend.api.BackendFolder.MoreMessages;
import com.fsck.k9.backend.api.BackendStorage;
import com.fsck.k9.backend.api.MessageRemovalListener;
import com.fsck.k9.backend.api.SyncConfig;
import com.fsck.k9.backend.api.SyncListener;
import com.fsck.k9.helper.ExceptionHelper;
@ -343,16 +342,6 @@ class Pop3Sync {
Timber.d("SYNC: Synced remote messages for folder %s, %d new messages", folder, newMessages.get());
if (purgeToVisibleLimit) {
backendFolder.purgeToVisibleLimit(new MessageRemovalListener() {
@Override
public void messageRemoved(Message message) {
listener.syncRemovedMessage(folder, message.getUid());
}
});
}
// If the oldest message seen on this sync is newer than
// the oldest message seen on the previous sync, then
// we want to move our high-water mark forward

View file

@ -15,7 +15,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import com.fsck.k9.backend.api.BackendFolder;
import com.fsck.k9.backend.api.BackendFolder.MoreMessages;
import com.fsck.k9.backend.api.BackendStorage;
import com.fsck.k9.backend.api.MessageRemovalListener;
import com.fsck.k9.backend.api.SyncConfig;
import com.fsck.k9.backend.api.SyncListener;
import com.fsck.k9.helper.ExceptionHelper;
@ -343,16 +342,6 @@ class WebDavSync {
Timber.d("SYNC: Synced remote messages for folder %s, %d new messages", folder, newMessages.get());
if (purgeToVisibleLimit) {
backendFolder.purgeToVisibleLimit(new MessageRemovalListener() {
@Override
public void messageRemoved(Message message) {
listener.syncRemovedMessage(folder, message.getUid());
}
});
}
// If the oldest message seen on this sync is newer than
// the oldest message seen on the previous sync, then
// we want to move our high-water mark forward