Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Migrate from sqflite (2)

ashilknb238ba2c6254
diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dart
index 0cb36daef5..b9f7328e50 100644
--- a/mobile/lib/db/files_db.dart
+++ b/mobile/lib/db/files_db.dart
@@ -660,13 +660,12 @@ class FilesDB {
}
Future<List<EnteFile>> getAllFilesCollection(int collectionID) async {
- final db = await instance.database;
+ final db = await instance.sqliteAsyncDB;
const String whereClause = '$columnCollectionID = ?';
final List<Object> whereArgs = [collectionID];
- final results = await db.query(
- filesTable,
- where: whereClause,
- whereArgs: whereArgs,
+ final results = await db.getAll(
+ 'SELECT * FROM $filesTable WHERE $whereClause',
+ whereArgs,
);
final files = convertToFiles(results);
return files;
@@ -676,14 +675,13 @@ class FilesDB {
int collectionID,
int addedTime,
) async {
- final db = await instance.database;
+ final db = await instance.sqliteAsyncDB;
const String whereClause =
'$columnCollectionID = ? AND $columnAddedTime > ?';
final List<Object> whereArgs = [collectionID, addedTime];
- final results = await db.query(
- filesTable,
- where: whereClause,
- whereArgs: whereArgs,
+ final results = await db.getAll(
+ 'SELECT * FROM $filesTable WHERE $whereClause',
+ whereArgs,
);
final files = convertToFiles(results);
return files;
@@ -705,20 +703,22 @@ class FilesDB {
inParam += "'" + id.toString() + "',";
}
inParam = inParam.substring(0, inParam.length - 1);
- final db = await instance.database;
+ final db = await instance.sqliteAsyncDB;
final order = (asc ?? false ? 'ASC' : 'DESC');
final String whereClause =
'$columnCollectionID IN ($inParam) AND $columnCreationTime >= ? AND '
'$columnCreationTime <= ? AND $columnOwnerID = ?';
final List<Object> whereArgs = [startTime, endTime, userID];
- final results = await db.query(
- filesTable,
- where: whereClause,
- whereArgs: whereArgs,
- orderBy:
- '$columnCreationTime ' + order + ', $columnModificationTime ' + order,
- limit: limit,
+ String query = 'SELECT * FROM $filesTable WHERE $whereClause ORDER BY '
+ '$columnCreationTime $order, $columnModificationTime $order';
+ if (limit != null) {
+ query += ' LIMIT ?';
+ whereArgs.add(limit);
+ }
+ final results = await db.getAll(
+ query,
+ whereArgs,
);
final files = convertToFiles(results);
final dedupeResult =