mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-07 10:40:11 -05:00
split apart "delete messages older than" for later reuse
This commit is contained in:
parent
f56afdbf93
commit
7d40596aa1
@ -3438,19 +3438,13 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati
|
||||
throw new MessagingException("Cannot call getUidFromMessageId on LocalFolder");
|
||||
}
|
||||
|
||||
public void deleteMessagesOlderThan(long cutoff) throws MessagingException
|
||||
private void deleteMessagesWhere(final String whereClause, final String[] params) throws MessagingException
|
||||
{
|
||||
final String where = "folder_id = ? and date < ?";
|
||||
final String[] params = new String[]
|
||||
{
|
||||
Long.toString(mFolderId), Long.toString(cutoff)
|
||||
};
|
||||
|
||||
open(OpenMode.READ_ONLY);
|
||||
Message[] messages = LocalStore.this.getMessages(
|
||||
null,
|
||||
this,
|
||||
"SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + where,
|
||||
"SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + whereClause,
|
||||
params);
|
||||
|
||||
for (Message message : messages)
|
||||
@ -3462,13 +3456,25 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati
|
||||
@Override
|
||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException
|
||||
{
|
||||
db.execSQL("DELETE FROM messages WHERE " + where, params);
|
||||
db.execSQL("DELETE FROM messages WHERE " + whereClause, params);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
resetUnreadAndFlaggedCounts();
|
||||
}
|
||||
|
||||
public void deleteMessagesOlderThan(long cutoff) throws MessagingException
|
||||
{
|
||||
final String where = "folder_id = ? and date < ?";
|
||||
final String[] params = new String[]
|
||||
{
|
||||
Long.toString(mFolderId), Long.toString(cutoff)
|
||||
};
|
||||
|
||||
deleteMessagesWhere(where, params);
|
||||
}
|
||||
|
||||
|
||||
private void resetUnreadAndFlaggedCounts()
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user