mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Also delete local messages when using "clear messages" on an account
We have been throwing away all attachments already, so it doesn't make too much sense to keep local messages. And when we're not keeping local messages we can remove all entries from the 'threads' table.
This commit is contained in:
parent
30e37000f9
commit
1a5ecfea1d
@ -285,24 +285,16 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
|
|
||||||
Log.i(K9.LOG_TAG, "After prune / before clear size = " + getSize());
|
Log.i(K9.LOG_TAG, "After prune / before clear size = " + getSize());
|
||||||
}
|
}
|
||||||
// don't delete messages that are Local, since there is no copy on the server.
|
|
||||||
// Don't delete deleted messages. They are essentially placeholders for UIDs of messages that have
|
|
||||||
// been deleted locally. They take up insignificant space
|
|
||||||
database.execute(false, new DbCallback<Void>() {
|
database.execute(false, new DbCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void doDbWork(final SQLiteDatabase db) {
|
public Void doDbWork(final SQLiteDatabase db) {
|
||||||
// Delete entries from 'threads' table
|
// We don't care about threads of deleted messages, so delete the whole table.
|
||||||
db.execSQL("DELETE FROM threads WHERE message_id IN " +
|
db.delete("threads", null, null);
|
||||||
"(SELECT id FROM messages WHERE deleted = 0 AND uid NOT LIKE 'Local%')");
|
|
||||||
|
|
||||||
// Set 'root' and 'parent' of remaining entries in 'thread' table to 'NULL' to make
|
// Don't delete deleted messages. They are essentially placeholders for UIDs of messages that have
|
||||||
// sure the thread structure is in a valid state (this may destroy existing valid
|
// been deleted locally.
|
||||||
// thread trees, but is much faster than adjusting the tree by removing messages
|
db.delete("messages", "deleted = 0", null);
|
||||||
// one by one).
|
|
||||||
db.execSQL("UPDATE threads SET root=id, parent=NULL");
|
|
||||||
|
|
||||||
// Delete entries from 'messages' table
|
|
||||||
db.execSQL("DELETE FROM messages WHERE deleted = 0 AND uid NOT LIKE 'Local%'");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user