Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aac921e2 authored by cketti's avatar cketti
Browse files

Remove local placeholder messages when emptying trash folder

parent a7a2e8dc
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -2174,12 +2174,11 @@ public class MessagingController {
            backend.expunge(trashFolderServerId);
        }

        // When we empty trash, we need to actually synchronize the folder
        // or local deletes will never get cleaned up
        // Remove all messages marked as deleted
        LocalStore localStore = localStoreProvider.getInstance(account);
        LocalFolder folder = localStore.getFolder(trashFolderServerId);
        folder.open();
        synchronizeFolder(account, folder, true, 0, null);
        folder.destroyDeletedMessages();

        compact(account, null);
    }
+9 −1
Original line number Diff line number Diff line
@@ -1610,11 +1610,19 @@ public class LocalFolder {
    }

    public void destroyLocalOnlyMessages() throws MessagingException {
        destroyMessages("uid LIKE '" + K9.LOCAL_UID_PREFIX + "%'");
    }

    public void destroyDeletedMessages() throws MessagingException {
        destroyMessages("empty = 0 AND deleted = 1");
    }

    private void destroyMessages(String messageSelection) throws MessagingException {
        localStore.getDatabase().execute(false, (DbCallback<Void>) db -> {
            try (Cursor cursor = db.query(
                    "messages",
                    new String[] { "id", "message_part_id", "message_id" },
                    "folder_id = ? AND uid LIKE '" + K9.LOCAL_UID_PREFIX + "%'",
                    "folder_id = ? AND " + messageSelection,
                    new String[] { Long.toString(databaseId) },
                    null,
                    null,