1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 09:08:49 -05:00

Split out deleteAttachment to avoid an extra SQL call if we can.

This commit is contained in:
Jesse Vincent 2010-08-29 16:56:45 +00:00
parent 38c31db8f6
commit 54a4c84afa

View File

@ -2261,23 +2261,10 @@ public class LocalStore extends Store implements Serializable
return PERMANENT_FLAGS;
}
private void deleteAttachments(String uid) throws MessagingException
private void deleteAttachments(long messageId) throws MessagingException
{
open(OpenMode.READ_WRITE);
Cursor messagesCursor = null;
try
{
messagesCursor = mDb.query(
"messages",
new String[] { "id" },
"folder_id = ? AND uid = ?",
new String[] { Long.toString(mFolderId), uid },
null,
null,
null);
while (messagesCursor.moveToNext())
{
long messageId = messagesCursor.getLong(0);
Cursor attachmentsCursor = null;
try
{
@ -2314,6 +2301,27 @@ public class LocalStore extends Store implements Serializable
}
}
}
private void deleteAttachments(String uid) throws MessagingException
{
open(OpenMode.READ_WRITE);
Cursor messagesCursor = null;
try
{
messagesCursor = mDb.query(
"messages",
new String[] { "id" },
"folder_id = ? AND uid = ?",
new String[] { Long.toString(mFolderId), uid },
null,
null,
null);
while (messagesCursor.moveToNext())
{
long messageId = messagesCursor.getLong(0);
deleteAttachments(messageId);
}
}
finally
{