From 6031862bad76e9af207d6311d95380d19ce46a76 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Sun, 29 Aug 2010 16:57:57 +0000 Subject: [PATCH] Before we delete messages earlier than the earliest acceptable date, make sure we also delete their attachments. --- src/com/fsck/k9/mail/store/LocalStore.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index bc7c532b7..63f557be3 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -2188,6 +2188,19 @@ public class LocalStore extends Store implements Serializable public void deleteMessagesOlderThan(long cutoff) throws MessagingException { open(OpenMode.READ_ONLY); + Message[] messages = LocalStore.this.getMessages( + null, + this, + "SELECT " + GET_MESSAGES_COLS + + "FROM messages WHERE folder_id = ? and date < ?", new String[] + { + Long.toString(mFolderId), Long.toString(cutoff) + }); + + for (Message message : messages) + { + deleteAttachments(message.getUid()); + } mDb.execSQL("DELETE FROM messages WHERE folder_id = ? and date < ?", new Object[] { Long.toString(mFolderId), new Long(cutoff)