From 31613e15c7fa12f7955edf015a48c89297a8dbc2 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 29 Aug 2010 16:56:54 +0000 Subject: [PATCH] extract the method for "delete a message" from the "Set flags" method --- src/com/fsck/k9/mail/store/LocalStore.java | 89 ++++++++++++---------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index a87c9581f..610a256c9 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -4775,47 +4775,7 @@ public class LocalStore extends Store implements Serializable { if (flag == Flag.DELETED && set) { - /* - * If a message is being marked as deleted we want to clear out it's content - * and attachments as well. Delete will not actually remove the row since we need - * to retain the uid for synchronization purposes. - */ - - /* - * Delete all of the messages' content to save space. - */ - ((LocalFolder) mFolder).deleteAttachments(getUid()); - - mDb.execSQL( - "UPDATE messages SET " + - "deleted = 1," + - "subject = NULL, " + - "sender_list = NULL, " + - "date = NULL, " + - "to_list = NULL, " + - "cc_list = NULL, " + - "bcc_list = NULL, " + - "preview = NULL, " + - "html_content = NULL, " + - "text_content = NULL, " + - "reply_to_list = NULL " + - "WHERE id = ?", - new Object[] - { - mId - }); - - /* - * Delete all of the messages' attachments to save space. - */ - mDb.execSQL("DELETE FROM attachments WHERE message_id = ?", - new Object[] - { - mId - }); - - ((LocalFolder)mFolder).deleteHeaders(mId); - + delete(); } else if (flag == Flag.X_DESTROYED && set) { @@ -4883,8 +4843,55 @@ public class LocalStore extends Store implements Serializable { Utility.combine(getFlags(), ',').toUpperCase(), mId }); + + } + private void delete() throws MessagingException + + { + /* + * Delete all of the message's content to save space. + */ + + mDb.execSQL( + "UPDATE messages SET " + + "deleted = 1," + + "subject = NULL, " + + "sender_list = NULL, " + + "date = NULL, " + + "to_list = NULL, " + + "cc_list = NULL, " + + "bcc_list = NULL, " + + "preview = NULL, " + + "html_content = NULL, " + + "text_content = NULL, " + + "reply_to_list = NULL " + + "WHERE id = ?", + new Object[] + { + mId + }); + + /* + * Delete all of the message's attachments to save space. + * We do this explicit deletion here because we're not deleting the record + * in messages, which means our ON DELETE trigger for messages won't cascade + */ + mDb.execSQL("DELETE FROM attachments WHERE message_id = ?", + new Object[] + { + mId + }); + + ((LocalFolder)mFolder).deleteAttachments(mId); + ((LocalFolder)mFolder).deleteHeaders(mId); + + + } + + + private void loadHeaders() {