Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Resolve conflicts and merge main

ashilkncae3748995c4
diff --cc mobile/lib/db/entities_db.dart
index 228e5e2b01,cee32641a0..004fdf0aee
--- a/mobile/lib/db/entities_db.dart
+++ b/mobile/lib/db/entities_db.dart
@@@ -9,41 -9,24 +9,41 @@@ extension EntitiesDB on FilesDB
List<LocalEntityData> data, {
ConflictAlgorithm conflictAlgorithm = ConflictAlgorithm.replace,
}) async {
- debugPrint("Inserting missing PathIDToLocalIDMapping");
+ debugPrint("entitiesDB: upsertEntities ${data.length} entities");
- final db = await database;
- var batch = db.batch();
+ final db = await sqliteAsyncDB;
+ final parameterSets = <List<Object?>>[];
int batchCounter = 0;
for (LocalEntityData e in data) {
+ parameterSets.add([
+ e.id,
+ e.type.name,
+ e.ownerID,
+ e.data,
+ e.updatedAt,
+ ]);
+ batchCounter++;
+
if (batchCounter == 400) {
- await batch.commit(noResult: true);
- batch = db.batch();
+ await db.executeBatch(
+ '''
+ INSERT OR ${conflictAlgorithm.name.toUpperCase()}
+ INTO entities (id, type, ownerID, data, updatedAt)
+ VALUES (?, ?, ?, ?, ?)
+''',
+ parameterSets,
+ );
+ parameterSets.clear();
batchCounter = 0;
}
- batch.insert(
- "entities",
- e.toJson(),
- conflictAlgorithm: conflictAlgorithm,
- );
- batchCounter++;
}
- await batch.commit(noResult: true);
+ await db.executeBatch(
+ '''
+ INSERT OR ${conflictAlgorithm.name.toUpperCase()}
+ INTO entities (id, type, ownerID, data, updatedAt)
+ VALUES (?, ?, ?, ?, ?)
+''',
+ parameterSets,
+ );
}
Future<void> deleteEntities(