Loading app/core/src/main/java/com/fsck/k9/mailstore/K9BackendFolder.kt +3 −5 Original line number Diff line number Diff line Loading @@ -51,15 +51,13 @@ class K9BackendFolder( return messageStore.getAllMessagesAndEffectiveDates(folderId) } // TODO: Move implementation from LocalFolder to this class override fun destroyMessages(messageServerIds: List<String>) { val localMessages = localFolder.getMessagesByUids(messageServerIds) localFolder.destroyMessages(localMessages) messageStore.destroyMessages(folderId, messageServerIds) } override fun clearAllMessages() { val messageServerIds = getMessageServerIds().toList() destroyMessages(messageServerIds) val messageServerIds = messageStore.getMessageServerIds(folderId) messageStore.destroyMessages(folderId, messageServerIds) } override fun getMoreMessages(): MoreMessages { Loading app/core/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +1 −16 Original line number Diff line number Diff line Loading @@ -1587,23 +1587,8 @@ public class LocalFolder { } } /** * Delete a message from the 'messages' and 'threads' tables. * * @param db * {@link SQLiteDatabase} instance to access the database. * @param messageId * The database ID of the message to delete. */ private void deleteMessageRow(SQLiteDatabase db, long messageId) { String[] idArg = { Long.toString(messageId) }; // Delete the message db.delete("messages", "id = ?", idArg); // Delete row in 'threads' table // TODO: create trigger for 'messages' table to get rid of the row in 'threads' table db.delete("threads", "message_id = ?", idArg); db.delete("messages", "id = ?", new String[] { Long.toString(messageId) }); } void deleteFulltextIndexEntry(SQLiteDatabase db, long messageId) { Loading app/core/src/main/java/com/fsck/k9/mailstore/MessageStore.kt +5 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,11 @@ interface MessageStore { */ fun getLastUid(folderId: Long): Long? /** * Remove messages from the store. */ fun destroyMessages(folderId: Long, messageServerIds: Collection<String>) /** * Create folders. */ Loading app/storage/src/main/java/com/fsck/k9/storage/StoreSchemaDefinition.java +2 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import timber.log.Timber; class StoreSchemaDefinition implements SchemaDefinition { static final int DB_VERSION = 78; static final int DB_VERSION = 79; private final MigrationsHelper migrationsHelper; Loading Loading @@ -243,6 +243,7 @@ class StoreSchemaDefinition implements SchemaDefinition { "BEGIN " + "DELETE FROM message_parts WHERE root = OLD.message_part_id; " + "DELETE FROM messages_fulltext WHERE docid = OLD.id; " + "DELETE FROM threads WHERE message_id = OLD.id; " + "END"); db.execSQL("DROP TABLE IF EXISTS messages_fulltext"); Loading app/storage/src/main/java/com/fsck/k9/storage/messages/AttachmentFileManager.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package com.fsck.k9.storage.messages import com.fsck.k9.K9 import com.fsck.k9.mailstore.StorageManager import com.fsck.k9.mailstore.StorageManager.InternalStorageProvider import java.io.File import timber.log.Timber class AttachmentFileManager( private val storageManager: StorageManager, private val accountUuid: String ) { fun deleteFile(messagePartId: Long) { val file = getAttachmentFile(messagePartId.toString()) if (file.exists() && !file.delete() && K9.isDebugLoggingEnabled) { Timber.w("Couldn't delete message part file: %s", file.absolutePath) } } private fun getAttachmentFile(messagePartId: String): File { val attachmentDirectory = storageManager.getAttachmentDirectory(accountUuid, InternalStorageProvider.ID) return File(attachmentDirectory, messagePartId) } } Loading
app/core/src/main/java/com/fsck/k9/mailstore/K9BackendFolder.kt +3 −5 Original line number Diff line number Diff line Loading @@ -51,15 +51,13 @@ class K9BackendFolder( return messageStore.getAllMessagesAndEffectiveDates(folderId) } // TODO: Move implementation from LocalFolder to this class override fun destroyMessages(messageServerIds: List<String>) { val localMessages = localFolder.getMessagesByUids(messageServerIds) localFolder.destroyMessages(localMessages) messageStore.destroyMessages(folderId, messageServerIds) } override fun clearAllMessages() { val messageServerIds = getMessageServerIds().toList() destroyMessages(messageServerIds) val messageServerIds = messageStore.getMessageServerIds(folderId) messageStore.destroyMessages(folderId, messageServerIds) } override fun getMoreMessages(): MoreMessages { Loading
app/core/src/main/java/com/fsck/k9/mailstore/LocalFolder.java +1 −16 Original line number Diff line number Diff line Loading @@ -1587,23 +1587,8 @@ public class LocalFolder { } } /** * Delete a message from the 'messages' and 'threads' tables. * * @param db * {@link SQLiteDatabase} instance to access the database. * @param messageId * The database ID of the message to delete. */ private void deleteMessageRow(SQLiteDatabase db, long messageId) { String[] idArg = { Long.toString(messageId) }; // Delete the message db.delete("messages", "id = ?", idArg); // Delete row in 'threads' table // TODO: create trigger for 'messages' table to get rid of the row in 'threads' table db.delete("threads", "message_id = ?", idArg); db.delete("messages", "id = ?", new String[] { Long.toString(messageId) }); } void deleteFulltextIndexEntry(SQLiteDatabase db, long messageId) { Loading
app/core/src/main/java/com/fsck/k9/mailstore/MessageStore.kt +5 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,11 @@ interface MessageStore { */ fun getLastUid(folderId: Long): Long? /** * Remove messages from the store. */ fun destroyMessages(folderId: Long, messageServerIds: Collection<String>) /** * Create folders. */ Loading
app/storage/src/main/java/com/fsck/k9/storage/StoreSchemaDefinition.java +2 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import timber.log.Timber; class StoreSchemaDefinition implements SchemaDefinition { static final int DB_VERSION = 78; static final int DB_VERSION = 79; private final MigrationsHelper migrationsHelper; Loading Loading @@ -243,6 +243,7 @@ class StoreSchemaDefinition implements SchemaDefinition { "BEGIN " + "DELETE FROM message_parts WHERE root = OLD.message_part_id; " + "DELETE FROM messages_fulltext WHERE docid = OLD.id; " + "DELETE FROM threads WHERE message_id = OLD.id; " + "END"); db.execSQL("DROP TABLE IF EXISTS messages_fulltext"); Loading
app/storage/src/main/java/com/fsck/k9/storage/messages/AttachmentFileManager.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line package com.fsck.k9.storage.messages import com.fsck.k9.K9 import com.fsck.k9.mailstore.StorageManager import com.fsck.k9.mailstore.StorageManager.InternalStorageProvider import java.io.File import timber.log.Timber class AttachmentFileManager( private val storageManager: StorageManager, private val accountUuid: String ) { fun deleteFile(messagePartId: Long) { val file = getAttachmentFile(messagePartId.toString()) if (file.exists() && !file.delete() && K9.isDebugLoggingEnabled) { Timber.w("Couldn't delete message part file: %s", file.absolutePath) } } private fun getAttachmentFile(messagePartId: String): File { val attachmentDirectory = storageManager.getAttachmentDirectory(accountUuid, InternalStorageProvider.ID) return File(attachmentDirectory, messagePartId) } }