mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 22:28:10 -05:00
Split out deleteAttachment to avoid an extra SQL call if we can.
This commit is contained in:
parent
38c31db8f6
commit
54a4c84afa
@ -2261,23 +2261,10 @@ public class LocalStore extends Store implements Serializable
|
|||||||
return PERMANENT_FLAGS;
|
return PERMANENT_FLAGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAttachments(String uid) throws MessagingException
|
|
||||||
|
private void deleteAttachments(long messageId) throws MessagingException
|
||||||
{
|
{
|
||||||
open(OpenMode.READ_WRITE);
|
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;
|
Cursor attachmentsCursor = null;
|
||||||
try
|
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
|
finally
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user