use batch transactions when writing roster
Fixes https://github.com/siacs/Conversations/issues/1648
This commit is contained in:
parent
3e9fd0185a
commit
ffb49c7217
|
@ -577,6 +577,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
public void writeRoster(final Roster roster) {
|
||||
final Account account = roster.getAccount();
|
||||
final SQLiteDatabase db = this.getWritableDatabase();
|
||||
db.beginTransaction();
|
||||
for (Contact contact : roster.getContacts()) {
|
||||
if (contact.getOption(Contact.Options.IN_ROSTER)) {
|
||||
db.insert(Contact.TABLENAME, null, contact.getContentValues());
|
||||
|
@ -586,6 +587,8 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
db.delete(Contact.TABLENAME, where, whereArgs);
|
||||
}
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
account.setRosterVersion(roster.getVersion());
|
||||
updateAccount(account);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue