mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-12 05:00:20 -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");
|
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);
|
open(OpenMode.READ_ONLY);
|
||||||
Message[] messages = LocalStore.this.getMessages(
|
Message[] messages = LocalStore.this.getMessages(
|
||||||
null,
|
null,
|
||||||
this,
|
this,
|
||||||
"SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + where,
|
"SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + whereClause,
|
||||||
params);
|
params);
|
||||||
|
|
||||||
for (Message message : messages)
|
for (Message message : messages)
|
||||||
@ -3462,13 +3456,25 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati
|
|||||||
@Override
|
@Override
|
||||||
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
resetUnreadAndFlaggedCounts();
|
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()
|
private void resetUnreadAndFlaggedCounts()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user